#include class Singleton { public: static Singleton* Instance(); static int get_number() { return number;} static void DelInstance(); protected: Singleton() { number ++; } ~Singleton() { number --; } private: static Singleton* _instance; static int number; }; int Singleton::number; Singleton* Singleton::_instance = 0; Singleton* Singleton::Instance () { if (_instance == 0) _instance = new Singleton; return _instance; } void Singleton::DelInstance() { delete _instance; _instance = 0; } using namespace std; int main() { cout << "number = " << Singleton::get_number() << endl; cout << "calling Instance" << endl; Singleton *sn = Singleton::Instance(); cout << "number = " << Singleton::get_number() << endl; cout << "calling DelInstance" << endl; Singleton::DelInstance(); cout << "number = " << Singleton::get_number() << endl; return 0; }