#include means: take this file and paste it at the place of the macro (because of the header guards - if it hasn't been included in this compilartion unit already).
So, OgreTest.cpp includes GameStateManager.h. GameStateManager.h includes GameState.h. GameState.h has #include "GameStateManager.h", but that header has already been included for OgreTest.cpp.
So, for OgreTest.cpp the compilation unit that the compiler will work with contains:
Code:
class CGameState
{
//...
//using CGameStateManager
};
class CGameStateManager
{
//...
};
int main()
{
//...
}
As you can see, CGameState ends up using CGameStateManager which will be declared later on. In C++ you can use only things that have been declared / defined earlier.
The solution is not to rearrange includes carefully. The solution is to separate declarations and implementations, and use forward declarations in more complicated cases (not the case here).