Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ------------------ MyClass.h -------------------- */
- #ifndef MY_SINGLETON
- #define MY_SINGLETON
- class MyClass
- {
- private:
- // member data
- int m_iNum;
- //constructor is private
- MyClass(){}
- //copy ctor and assignment should be private
- MyClass(const MyClass &);
- MyClass& operator=(const MyClass &);
- public:
- //strictly speaking, the destructor of a singleton should be private but some
- //compilers have problems with this so I’ve left them as public in all the
- //examples in this book
- ~MyClass();
- //methods
- int GetVal()const{return m_iNum;}
- static MyClass* Instance();
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement