31 #include <Base/Common/Singleton.hh>
44 MyClass() : data(0) {}
45 MyClass(
const MyClass &a) : data(a.data) {}
46 MyClass& operator=(
const MyClass& a) { data = a.data;
return *
this; }
55 MyClassSingleton::GetInstance()->data = 5;
60 int main(
int argc,
char *argv[])
62 cout <<
"initial data: " << MyClassSingleton::GetInstance()->data << endl;
66 cout <<
"after function: " << MyClassSingleton::GetInstance()->data << endl;
68 cout <<
"accessing Singleton<MyClass> is identical to MyClassSingleton: "
Simple singleton implementation for multithreaded applications.