newwy
奋斗在IT路上的小蜗牛。一步一步往上爬,爬到小牛,在到大牛,然后是神牛,然后是犇,然后就可以离开IT行业,回归大自然了。 远离IT,珍爱生命!!! 记录学习的点滴。
/*********************************
*设计模式--单件实现
*C++语言
*Author:WangYong
*Blog:http://www.cnblogs.com/newwy
********************************/
#include <iostream>
using namespace std;

class Singleton
{
public:
	static Singleton * Instance()
	{
		if(_instance == 0)
			_instance = new Singleton();
		return _instance;
	}
protected :
	Singleton () {cout<<"Singleton ....";}
private:
	static Singleton * _instance;
};
Singleton* Singleton::_instance = 0;

int main()
{
	Singleton *sgn = Singleton::Instance();
	return 0;
}


posted on 2010-10-18 23:35  newwy  阅读(282)  评论(0编辑  收藏  举报