Listing 3: A singleton that creates an instance as a local static object
// try2.h class Singleton { public: static Singleton& instance(); void show_state(); protected: Singleton(); private: int state; }; Singleton& Singleton::instance() { static Singleton _instance; return _instance; }