设计模式(Singleton)
来源:互联网 发布:淘宝 卖家中心不见了 编辑:程序博客网 时间:2024/05/21 06:31
#include <iostream>
using namespace std;
class CSingleton
{
private:
CSingleton();
public:
virtual ~CSingleton();
public:
static CSingleton *GetInstance();
private:
static CSingleton *s_pSingleton;
};
CSingleton *CSingleton::s_pSingleton = NULL;
CSingleton::CSingleton()
{
}
CSingleton::~CSingleton()
{
if(CSingleton::s_pSingleton != NULL)
{
delete CSingleton::s_pSingleton;
CSingleton::s_pSingleton = NULL;
}
}
CSingleton *CSingleton::GetInstance()
{
if(CSingleton::s_pSingleton == NULL)
{
CSingleton::s_pSingleton = new CSingleton();
}
return CSingleton::s_pSingleton;
}
void main()
{
for(int i = 0; i < 10; i++)
{
CSingleton *pSingleton = CSingleton::GetInstance();
cout<<i<<"/t"<<pSingleton<<endl;
}
}
- 设计模式-----Singleton模式
- 设计模式-Singleton模式
- 设计模式--Singleton模式
- 设计模式-------Singleton模式
- 设计模式--singleton模式
- 设计模式--Singleton模式
- 【设计模式】--SINGLETON模式
- 探究 Singleton 设计模式
- 探究Singleton设计模式
- 设计模式之singleton
- 设计模式之Singleton
- [设计模式]Singleton
- 设计模式之singleton
- 设计模式之 Singleton
- SharpDevelop设计模式(Singleton)
- 设计模式 Singleton
- 探究Singleton设计模式
- 设计模式之Singleton
- 剪切板上文本数据的传送
- 动态生成控件
- MFC小笔记
- 学习SQL应知道的动态SQL语句基本语法
- 指针与数组的区别
- 设计模式(Singleton)
- C中的Volatile用法
- SQL Server数据库中经常用到的identity列
- 设计模式(Decorator)
- 哈佛图书馆训言
- 设计模式(Strategy)
- hiberante 中generator属性的所示意义
- 通用SQL数据库的查询语句 (1)
- 设计模式(Abstract Factory)