
单例模式简短代码
class singleton //实现单例模式的类 { private: singleton() {} //私有构造函数 static singleton *instance; //静态类指针 public: static singleton *GetInstance() //静态成员函数 { if(Instance == NULL) //判断是否是第一次调用· Instance = new singleton(); return Instance; } }
👁️ 阅读量:0
© 版权声明:本文《单例模式简短代码》内容均为本站精心整理或网友自愿分享,如需转载请注明原文出处:https://www.zastudy.cn/wen/1686862538a358289.html。