I made a virtual base class 'GameState' and derive the various states from it. The states are pushed in a std::vector<GameState*>
At first I declared the class holding the vector, the GameState base class, and derived states classes all in the same header and implemented them in the same source file, and everything was ok. There is a function called by the states that changes the current state
[source lang="cpp"]void ChangeState(GameState* newstate)[/source]
Then I decided to put each class in a separate header-source and the problem appeared.
If i try to pass to it, say, a pointer to an instance of class PlayState (derived from GameState) the compiler gives the following error
error: no matching function for call to 'GameManager::ChangeState(PlayState*&)'
note: candidates are: void GameManager::ChangeState(GameState*)
'game' is a pointer to GameManager that every state has
GameManager holds the vector and pointers to states' instances (like play_state).
Trying random stuff, I noticed that if I include the headers of each derived state in GameManager.h (instead of GameManager.cpp) the problem gets fixed (at first I just forward declared the classes since GameManager holds only pointers).
I'd like help in understanding what's going on. Sorry if the explanation isn't very clear but I have trouble identifying the issue myself and I didn't want fill the post with all the headers (I'll do it if it's necessary though)
Edited by Maeriden, 28 June 2012 - 07:29 PM.