Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. /* ------------------ MyClass.h -------------------- */
  2. #ifndef MY_SINGLETON
  3. #define MY_SINGLETON
  4. class MyClass
  5. {
  6. private:
  7.  
  8. // member data
  9. int m_iNum;
  10.  
  11. //constructor is private
  12. MyClass(){}
  13.  
  14. //copy ctor and assignment should be private
  15. MyClass(const MyClass &);
  16. MyClass& operator=(const MyClass &);
  17.  
  18. public:
  19.  
  20. //strictly speaking, the destructor of a singleton should be private but some
  21. //compilers have problems with this so I’ve left them as public in all the
  22. //examples in this book
  23. ~MyClass();
  24.  
  25. //methods
  26. int GetVal()const{return m_iNum;}
  27. static MyClass* Instance();
  28. };
  29. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement