Last active
December 11, 2015 17:58
Revisions
-
mhseiden revised this gist
Jan 25, 2013 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,7 @@ /** * NOTE - I haven't compiled this, so there may be small errors. * However, the concepts shown are correct. */ // In the *.h file class MyClass; -
mhseiden created this gist
Jan 25, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ // NOTE - I haven't compiled this, so there may be small errors. However, the concepts shown are correct. // In the *.h file class MyClass; class MyClass { public: /** Static Singleton accessor. Use a ref for easy access and use **/ static MyClass& get(); /** Instance Methods **/ // ... private: MyClass(); // Constructor ~MyClass(); // Destructor // Could hide equals operator and copy constructor... /** Other private data **/ // ... }; // In the *.c file static MyClass& MyClass::get() { static MyClass singleton; return singleton; }