Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which `main` is used if I specify more than one

Tags:

c++

Along with a couple of others, the following are valid prototypes for main():

  1. int main(void)

  2. int main(int, char**)

In C we can't overload functions so it's never possible to have both. But in C++ that's not true. If I were to have both in a compiled C++ executable, then which one is used? Does it depend on the command line? What does the standard say?

like image 984
P45 Imminent Avatar asked Dec 16 '14 16:12

P45 Imminent


1 Answers

C++11 §3.6.1/2:

This function shall not be overloaded.

like image 83
Cheers and hth. - Alf Avatar answered Nov 10 '22 05:11

Cheers and hth. - Alf