Guest User

Untitled

a guest
Jul 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #pragma once
  2.  
  3. class SingletonObject
  4. {
  5. public:
  6. static SingletonObject* SingletonObject();
  7. static void SingletonObject();
  8. private:
  9. static SingletonObject* sSingletonObject;
  10. SingletonObject();
  11. ~SingletonObject();
  12. };
  13.  
  14. #include "SingletonObject.h"
  15.  
  16. SingletonObject* SingletonObject::sSingletonObject = NULL;
  17.  
  18. SingletonObject:: SingletonObject()
  19. {
  20. }
  21.  
  22. SingletonObject::~ SingletonObject()
  23. {
  24. }
  25.  
  26. SingletonObject* SingletonObject::GetSingleton()
  27. {
  28. if (sSingletonObject == NULL) // cache miss
  29. {
  30. sSingletonObject = new SingletonObject();
  31. }
  32. return sSingletonObject;
  33. }
  34.  
  35. void SingletonObject::DestroySingleton()
  36. {
  37. delete sSingletonObject;
  38. sSingletonObject = NULL;
  39. }
Add Comment
Please, Sign In to add comment