+ 3
Is there anyway if we can replace main method from c++, or can we override or overload main method???
this question is about c++ programming as we always run c++ program the compiler invokes main method first of all. My question is why we can't replace it with anyother method?
3 Antworten
+ 3
Yes, you can. But to do this you have to change in Visual Studio linker settings!
+ 2
1) Why would you want to?
2) main is not a method.
+ 1
Thats how the language works. You cannot replace or override main, but you can do :
#define start main
int start()
{
// do stuff you would earlier do in main.
}
And obviously, you can use C++ to write a new language that does not require this 'main' function at all. Its your wish though, what you want to do.
Also visit :
https://stackoverflow.com/questions/7050925/is-it-possible-to-write-a-program-without-using-main-function
https://stackoverflow.com/questions/5282151/can-we-overload-main-function-in-c