I have my abstract CGameState class, which has 3 virtual functions: Logic, Events and Render. Then I have my CGame class, that contains the CGameState* object, the screen object and methods that change the state.
The main loop is like:
Now, if during the application there is a need to change the state, I am using ChangeState method, which basically deletes the old CGameState* and creates the proper new one. For example:
And the CMenu inherites from the CGameState, to use its own Logic, Events, and Render methods.
Here goes the problem:
When there is a need to change the state, I have no access to the (Cgame game) object, because it contains the CurrentState object.. So I cannot use the ChangeState method :/ How can I do it?