谈谈C++中的单例 下载 qq_33079 4 0 PDF 2021-01-16 22:01:56 写C++的时候用到单例,于是很自然的写出如下的代码: namespace tlanyan { class Foo { private: static Foo* _instance; Foo() {} // other members public: static Foo* getInstance() { if (_instance == NULL) { _instance = new Foo(); } return _instance; } ~Foo() { // cl 立即下载 微信扫一扫:分享 微信里点“发现”,扫一下 二维码便可将本文分享至朋友圈。