1. 首页
  2. 数据库
  3. 其它
  4. 谈谈C++中的单例

谈谈C++中的单例

上传者: 2021-01-16 22:19:56上传 PDF文件 64.09KB 热度 7次
写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
下载地址
用户评论