How do I call main() in my main cpp file from a seperate cpp file?

前端 未结 5 1027
失恋的感觉
失恋的感觉 2021-01-29 14:33

I\'m making a class that displays a message to the user and asks them if they want to return to the start of the program, but the message function is in a separate class from wh

5条回答
  •  情深已故
    2021-01-29 14:45

    In C++ it is illegal for a program to call main itself, so the simple answer is you don't. You need to refactor your code, the simplest transformation is to write a loop in main, but other alternatives could include factoring the logic out of main into a different function that is declared in a header and that you can call.

提交回复
热议问题