I know this might be a fairly broad subject. Basically, I'm teaching myself c++ through books and online resources before I start actual classes in about 5 or 6 months (need to take prereqs first). As part of practice, as I learn more, I'd like to create a game so I can keep putting what I learn to use and remembering everything I learn. I'd like to create a sort of text version of Sim City. What my question is, is this:
I have a menu,
1. start game
2. load
3. quit
I'll figure out each one as I continue learning. What I'm curious is that when I want to start a game, where does my code go from there? I'm using a switch statement to choose from the options, and I have that working. But I don't want the code for actually playing the game from my main.cpp source file, do I? I have the other options disabled for now to return 0 and end the program but Start game will actually, obviously, be the core of it. But I don't want the entire game that's played coming from the same source file, for organizational's sake. I'm not looking for entire code to solve my question, just hints and nudges to help me out if possible.
If this question is too vague, I'll try and be more specific in a response. Thank you!
From that case in your switch you will call a function playGame(). You can then define that function wherever you like. If you want to do it in another .cpp file, write a .h containing the declaration of playGame(). Then include that header file in both cpps. Don't forget to compile both cpps.