Guest User

Untitled

a guest
Jun 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. template<typename T> class Singleton {
  2.   T* instance;
  3.  
  4. public:
  5.   T& getInstance() {
  6.     if(!instance) {
  7.       instance = new T();
  8.     }
  9.     return *instance;                                        
  10.   }                                                                                                                                                                                                                
  11. };
Add Comment
Please, Sign In to add comment