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

📄 singleton.cc

📁 day77_1187669327.zip
💻 CC
字号:
#include <iostream>using namespace std;class Single{	int data;	Single(){}	Single(const Single& o){}	//static int s;	static Single obj;public:	static Single& getInstance(){		return obj;	}	void set(int d){		data = d;	}	void show(){		cout << "this=" << this << ", ";		cout << "data=" << data << endl;	}};//int Single::s;Single Single::obj;int main(){	Single& s1=Single::getInstance();	Single& s2=Single::getInstance();	s1.set(100);	s1.show();	s2.show();	//Single s3;//ERROR!!	//Single s4(s1);//ERROR!!	//Single s5=s1;//ERROR!!}

⌨️ 快捷键说明

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