Created
December 31, 2015 00:46
-
-
Save xaxxon/f6eb8335686bd1047f49 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
template <class T> | |
class Singleton | |
{ | |
public: | |
static T* Instance() { | |
if(!m_pInstance) m_pInstance = new T; | |
assert(m_pInstance != NULL); | |
return m_pInstance; | |
} | |
protected: | |
Singleton(); | |
~Singleton(); | |
private: | |
Singleton(Singleton const&); | |
Singleton& operator=(Singleton const&); | |
static T* m_pInstance; | |
}; | |
template <class T> T* Singleton<T>::m_pInstance=NULL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment