+ 3
Why can not we have 2 main functions in a single program
9 Answers
+ 7
No we can have one and only one main() in every executable. When you run the executable, os runs the main function in that executable. It will create ambiguity if there are two main functions.
+ 3
A previous discussion regarding main function, you might find to be interesting:
https://www.sololearn.com/Discuss/1349922/?ref=app
+ 3
Sounds like âWhy canât we have 2 mothers?â
Because to âbornâ a program we need only 1 Main() method and one pair of straight handsâșïž
+ 2
if we have tow main function
the compiler confused and says from where i can excute the program?
from main1 or 2
+ 2
it will create an ambiguity for the compiler where to start the program
+ 2
that's like having two start buttons. which start button do you press?
+ 2
any program will start execution from main func so if there is two main func then the compiler will get confused where to start the prog running
+ 1
main is the entry point to your app so there's one main to run the app thread
0
because main is the entry point to your app so there must be one entry to app . suppose you have 2 main which one to be thread to app and compiler doesnot know which one to start with