/*********************************
*设计模式--单件实现
*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;
}


相关文章:

  • 2021-10-16
  • 2021-11-04
  • 2021-07-05
  • 2021-10-01
  • 2022-12-23
  • 2022-01-31
  • 2022-12-23
猜你喜欢
  • 2022-02-27
  • 2022-12-23
  • 2022-01-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
相关资源
相似解决方案