单例模式
#include <iostream> class Singleton { public: Singleton(const Singleton&) = delete; Singleton& operator = (const Singleton&) = delete; static Singleton& get_instance() { static Singleton instance; return instance; } void show() { std::cout << "In Singleton show()." << std::endl; } private: Singleton() {} }; int main(int argc, char *argv[]) { Singleton& instance = Singleton::get_instance(); instance.show(); return 1; }