Skip to content

Instantly share code, notes, and snippets.

@xaxxon
Created December 31, 2015 00:46
Show Gist options
  • Save xaxxon/70bd3b4c42b743092b6e to your computer and use it in GitHub Desktop.
Save xaxxon/70bd3b4c42b743092b6e to your computer and use it in GitHub Desktop.
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