Created
December 31, 2015 00:46
-
-
Save xaxxon/70bd3b4c42b743092b6e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
05 | |
template <class T> | |
06 | |
class Singleton | |
07 | |
{ | |
08 | |
public: | |
09 | |
static T* Instance() { | |
10 | |
if(!m_pInstance) m_pInstance = new T; | |
11 | |
assert(m_pInstance != NULL); | |
12 | |
return m_pInstance; | |
13 | |
} | |
14 | |
protected: | |
15 | |
Singleton(); | |
16 | |
~Singleton(); | |
17 | |
private: | |
18 | |
Singleton(Singleton const&); | |
19 | |
Singleton& operator=(Singleton const&); | |
20 | |
static T* m_pInstance; | |
21 | |
}; | |
22 | |
23 | |
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