GENEIAL  0.2=/
 All Classes Pages
Singleton.h
1 #pragma once
2 
3 template<typename C>
4 class singleton
5 {
6 public:
7  static C* instance()
8  {
9  if (!_instance)
10  _instance = new C();
11  return _instance;
12  }
13  virtual ~singleton()
14  {
15  delete _instance;
16  _instance = 0;
17  }
18 private:
19  static C* _instance;
20 protected:
21  singleton()
22  {
23  }
24 };
25 template<typename C> C* singleton<C>::_instance = 0;
26 
Definition: Singleton.h:4