⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unique.cpp

📁 自己写的c++实现的headfirst中的设计模式
💻 CPP
字号:
/* *单件模式
 * 无法实现?链接错误!
 */

#include <iostream>

using namespace std;

class Singleton
{
private:
	static Singleton* uniqueInstance;
	Singleton();
	
public:
	static Singleton* getStruct()
	{
		if (uniqueInstance==NULL) uniqueInstance=new Singleton;
		else cout << "can not create!";
		return uniqueInstance;
	}
	
	void function()
	{
		cout << "fonction!";
	}
};

void unique_main()
{
	//Singleton s;
	//Singleton *s=Singleton::getStruct();
	//s->function();

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -