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

前端 未结 5 969
失恋的感觉
失恋的感觉 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

    Maybe something like that:

    bool dispMessage(void)
    {
      cout << "This is my message" << endl;
      // call me again
      return true;
    
      // do not call me again
      return false;
    }
    

    and in the int main():

    int main()
    {
      Message DisplayMessage;
      while(DisplayMessage.dispMessage())
      {
    
      }
      return 0;
    } 
    

提交回复
热议问题