Singleton Example by Dar135th Jul 2012 22:44
|
---|
Summary This is an example of the singleton programming style in C++. Description This is a simple singleton-style class. It isn't as feature-rich or pretty as some other implementations(see Ogre3D's Ogre::Singleton Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com //Simple implementation of a singleton by Dar13 class foo { private: //These HAVE to be PRIVATE. foo() {} foo(const foo& copy) {} foo& operator=(const foo& copy) {} public: //VERY IMPORTANT FUNCTION static foo& getInstance() { static foo instance; return instance; } //class members go here. void printBabble() { printf("BLaH BlaH"); } private: //private class members }; |