Samsung Electronics interview question

Write the C++ declaration for a Singleton Class

Interview Answer

Anonymous

Feb 29, 2012

class foo { public: static foo& Instance() { static foo singleton; return singleton; } // Other non-static member functions private: foo() {}; foo(const foo&); foo& operator=(const foo&); };