Created
August 28, 2012 11:17
-
-
Save thenonameguy/3497326 to your computer and use it in GitHub Desktop.
Singleton base
This file contains 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 characters
class S | |
{ | |
public: | |
static S& getInstance() | |
{ | |
static S instance; // Guaranteed to be destroyed. | |
// Instantiated on first use. | |
return instance; | |
} | |
private: | |
S(); | |
// Dont forget to declare these two. You want to make sure they | |
// are unaccessable otherwise you may accidently get copies of | |
// your singleton appearing. | |
S(S const&); // Don't Implement | |
void operator=(S const&); // Don't implement | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment