标签:单例模式实例
#include "stdafx.h"
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class CSingleton
{
private:
CSingleton() //构造函数是私有的
{
}
static CSingleton *m_pInstance;
public:
static CSingleton * GetInstance()
{
if(m_pInstance == NULL) //判断是否第一次调用
m_pInstance = new CSingleton();
return m_pInstance;
}
};
CSingleton* CSingleton::m_pInstance=NULL;
int main()
{
CSingleton* s1=CSingleton::GetInstance();
system("pause");
return 0;
}标签:单例模式实例
原文地址:http://blog.csdn.net/cjc211322/article/details/38981821