#include <cstdlib>
#include <iostream>
using namespace std;
class Singleton
{
Singleton(){}
Singleton(Singleton&a);
Singleton& operator=(const Singleton&);
public:
~Singleton(){
if(pSing != NULL)
//delete pSing;
pSing = NULL;
}
void Do(){cout<<"我是唯一的"<<endl;}
static Singleton* pSing;
static Singleton* Instance()
{
if(pSing == NULL)pSing = new Singleton;
return pSing;
}
};
Singleton* Singleton::pSing = NULL;
int main(int argc, char *argv[])
{
Singleton* pSing = Singleton::Instance();
pSing->Do();
pSing = Singleton::Instance();
pSing->Do();
delete pSing;
system("PAUSE");
return EXIT_SUCCESS;
}