标签:span 模式 instance stat tin single blog ++ 单例
自己写的单例模式
class singleton{ public: singleton(const singleton&) = delete; singleton& operator=(const singleton& rhs) = delete; static singleton* getinstance(){ if (ptr == NULL) { ptr = new singleton(); return ptr; } else return NULL; } int geta(){ return a; } private: static singleton* ptr; singleton(){ a = 5; } int a; }; Singleton* Singleton::ptr = NULL;
标签:span 模式 instance stat tin single blog ++ 单例
原文地址:http://www.cnblogs.com/hchacha/p/7674727.html