The compiler is complaining about my singleton class I am creating. It's pretty simple.
Here is the .h file:
Here is the cpp file:Code:class GAME_MANAGER { private: //Single instance of the GAME_MANAGER class static GAME_MANAGER *gameManagerInstance; //Constructors and assignment operator - private GAME_MANAGER ( ) { }; GAME_MANAGER ( const GAME_MANAGER © ) { }; void operator = ( const GAME_MANAGER &rhs ) { }; public: static GAME_MANAGER *GetInstance ( ); };
As far as I know this is the way singletons are supposed to be done in C++, but it is really complaining at me a lot.Code:#include "game_manager.h" GAME_MANAGER *GAME_MANAGER::gameManagerInstance = NULL; static GAME_MANAGER::GAME_MANAGER *GetInstance ( ) { if ( !gameManagerInstance ) { gameManagerInstance = new GAME_MANAGER(); } return gameManagerInstance; }
The errors are as follows:
Any ideas what is going wrong?game_manager.cpp||In function `GAME_MANAGER* GetInstance()':|
game_manager.cpp|7|error: `gameManagerInstance' was not declared in this scope|
inc\game_manager.h|25|error: `GAME_MANAGER::GAME_MANAGER()' is private|
game_manager.cpp|9|error: within this context|
game_manager.cpp|12|error: `gameManagerInstance' was not declared in this scope|
||=== Build finished: 4 errors, 0 warnings ===|
Oh...I am using Code::Blocks, and the compiler appears to be GCC 3.4.5.
Thanks