Two main functions

前端 未结 8 839
孤独总比滥情好
孤独总比滥情好 2020-12-19 10:20

Can we have two main() functions in a C++ program?

8条回答
  •  春和景丽
    2020-12-19 10:50

    Yes! Why not?

    Consider the following code:

     namespace ps
     {
         int main(){return 0;}
     }
    
     int main()
     {
         ps::main();
     }
    

    Its ::main() that will be called during execution.

提交回复
热议问题