34 lines
440 B
C++
34 lines
440 B
C++
#pragma once
|
|
|
|
template <class T>
|
|
class Singleton
|
|
{
|
|
public:
|
|
Singleton(void){}
|
|
~Singleton(void){}
|
|
|
|
private:
|
|
static T* m_pInstance;
|
|
|
|
public:
|
|
static T* Instance()
|
|
{
|
|
if( !m_pInstance )
|
|
m_pInstance = new T;
|
|
|
|
return m_pInstance;
|
|
}
|
|
|
|
static VOID DestroyInstance()
|
|
{
|
|
if( m_pInstance )
|
|
delete m_pInstance;
|
|
|
|
m_pInstance = NULL;
|
|
}
|
|
};
|
|
|
|
// 명시적으로 초기화 하지않아도 0이다
|
|
template< class T >
|
|
T* Singleton<T>::m_pInstance = NULL;
|