Skip to content

Instantly share code, notes, and snippets.

@thenonameguy
Created August 28, 2012 11:17
Show Gist options
  • Save thenonameguy/3497326 to your computer and use it in GitHub Desktop.
Save thenonameguy/3497326 to your computer and use it in GitHub Desktop.
Singleton base
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