Cpp main method const declaration

75 Views Asked by At

Why can't we declare main method as const in CPP??

int main() const 
{
   //Some code
}

Someone can please tell me why?

1

There are 1 best solutions below

4
R Sahu On BEST ANSWER

Why can't we declare main method as const in CPP??

const qualifiers can be used only to declare member functions of classes. It is not an option for non-member functions, which main is one.