#include <iostream>
using namespace std;
class Singleton {
private:
Singleton() { }
~
Singleton() { }
static Singleton*
pSingleton;
public:
static Singleton*
GetInstance() {
if (pSingleton ==
NULL) {
pSingleton =
new Singleton();
}
return pSingleton;
}
};
Singleton*
Singleton::pSingleton;
int main()
{
Singleton* p1 =
Singleton::GetInstance();
cout<<hex<<p1<<
endl;
Singleton* p2 =
Singleton::GetInstance();
cout<<hex<<p2<<
endl;
return 0;
}
转载于:https://www.cnblogs.com/yanjiu/archive/2012/08/20/2647987.html
相关资源:数据结构—成绩单生成器
转载请注明原文地址: https://win8.8miu.com/read-1542285.html