Can we overload main() function in C++? [duplicate]
问题 This question already has answers here : Is main() overloaded in C++? (6 answers) Closed 2 years ago . Since C+++ allows function overloading, can we overload main() ? For example, int main(const std::string &) { return 0; } int main(int argc, char *argv[]) { return main("calling overloaded main"); } gcc-4.3.4 doesn't compile this, and gives these errors: (see at ideone) prog.cpp:4: error: first argument of ‘int main(const std::string&)’ should be ‘int’ prog.cpp:4: error: ‘int main(const std: