Last active
September 11, 2017 12:41
-
-
Save korken89/e0167344160577dad90eea2adb99b653 to your computer and use it in GitHub Desktop.
Singleton definition, just to remember
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& instance() { | |
static Singleton instance_; | |
return instance_; | |
} | |
private: // use protected: if it should be inherited from | |
Singleton() = default; | |
~Singleton() = default; | |
Singleton(const Singleton&) = delete; | |
Singleton& operator=(const Singleton&) = delete; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Make any class into a singleton: