单间模式,求解释。
// ThinkingInCpp.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <iostream>using namespace std;class Singleton{private: static Singleton s; int i; Singleton(int x):i(x){} void operator=(Singleton &s){s.i = this->i;}; Singleton(Singleton &s){this->i = s.i;}public: static Singleton & getHandle() { return s; } int getValue() { return i; } void setValue(int x) { i = x; }};Singleton Singleton::s(50); //发生了什么,有没有s对象 int _tmain(int argc, _TCHAR* argv[]){ Singleton & s = Singleton::getHandle (); //发生了什么。 cout<<s.getValue()<<endl; system("pause"); return 0;}