#ifndef SINGLETON_H #define SINGLETON_H #include // atexit template class Singleton { public: static T& instance() { if (value_ == 0) { value_ = new T(); } return *value_; } private: Singleton(); ~Singleton(); static void init() { value_ = new T(); } static void destroy() { delete value_; } private: static T* value_; }; template T* Singleton::value_ = NULL; #endif