Created
April 18, 2014 20:51
-
-
Save nopjia/11063843 to your computer and use it in GitHub Desktop.
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 Singleton { | |
public: | |
static Singleton& getInstance() | |
{ | |
static Singleton instance; // Guaranteed to be destroyed. | |
// Instantiated on first use. | |
return instance; | |
} | |
private: | |
Singleton() {}; // Constructor (the {} brackets) are needed here. | |
// Declare copy constructors to be unaccessible | |
Singleton(Singleton const&); // Don't implement | |
void operator=(Singleton const&); // Don't implement | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment