Sphere: Related Content
#include <iostream>
using namespace std;
class Singleton
{
static Singleton s;
int i;
Singleton(int x) : i(x)
{
cout << "private constructor" << endl;
}
void operator=(Singleton&);
Singleton(const Singleton&);
public:
static Singleton& getHandle()
{
cout << "calling getHandle()" << endl;
return s;
}
int getValue() { return i; }
void setValue(int x) { i = x; }
};
Singleton Singleton::s(47);
int main()
{
//Singleton s1;
Singleton& s = Singleton::getHandle();
cout << s.getValue() << endl;
Singleton& s2 = Singleton::getHandle();
s2.setValue(9);
cout << s.getValue() << endl;
}
‘We are sorry for the outcome’: Masagos acknowledges agencies could have
done more in Megan Khung case
-
Two police officers have been disciplined, and a child protective service
officer from the Ministry of Social and Family Development is being
investigated.
4 minutes ago

No comments:
Post a Comment