Advertisement
kamos

Singleton

Oct 1st, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. template<class T>
  2. class CSingleton {
  3. private:
  4.     static T* m_object = NULL;
  5. public:
  6.     CSingleton() = delete;
  7.     ~CSingleton() = delete;
  8.     CSingleton(const CSingleton&) = delete;
  9.     CSingleton& operator= (const CSingleton&) = delete;
  10.     static T* get_instance() {
  11.         if(!m_object) m_object = new T();
  12.         return m_object;
  13.     }
  14. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement