Another polymorphic approach would be something like this:
class GameState
{
public:
virtual ~GameState() { }
virtual GameState* Run() = 0;
};
// .. derive different game states from GameState, such as
// TitleScreen, Settings, MainGame, etc
// .. then in main:
GameState* currentstate = new TitleScreen;
while(currentstate != 0)
{
GameState* nextstate = currentstate->Run();
delete currentstate;
currentstate = nextstate;
}
The idea is that each game state then returns an instance of the next state to run. So TitleScreen::Run would return "new MainGame;" or "new SettingsMenu;" or something depending on whatever options the user took at the opening menu.
Just have run return 0 when you want the program to close.
EDIT: another advantage of this is that you can nest states. For example, you could call Run from inside other Run functions (for instance if you wanted to open the SettingsMenu from MainGame, or something like that).
In which case returning 0 would mean "go back to the previous state" instead of "close the program"
EDIT 2:
Also, is that something that a beginner should be worried about?
Yes. Code organization is a big deal. I can't tell you how many projects I've ultimately dropped because over time the code just became too messy to work on any more.