Why cant I overload main - when its already overloaded?!
If there are two versions of main() why cant I overload them in my code, when they are already overloaded as two of the same function for C++?
test1.cpp
Code:
#include <iostream>
using namespace std;
//function overloading of main();
int main(void);
int main(int argc, char *argv[]);
int main(void)
{
cout << "hello world" << endl;
return 0;
}
int main(int argc, char *argv[])
{
int x;
for(x = 0;x < argc;x++) { cout << argv[x] << endl; }
return 0;
}
gcc 4.8.1 wont let me compile this even though its a valid c++ function like any other function from what I have read in my c++ textbook . The book doesn't mention main() as an exception, so I thought that if there are two versions of main() that are valid, function overloading of main() could be done.
Thanks