#pragma once template class CSingleton { public: CSingleton() {} virtual ~CSingleton() {} static void CreateClass() { if ( !m_pMgr ) m_pMgr = new T; } static void DestroyClass() { if ( m_pMgr ) { delete m_pMgr; m_pMgr = NULL; } } static T* GetMgr() { return m_pMgr; } private: static T* m_pMgr; }; template T* CSingleton::m_pMgr = NULL;