单例类
記錄一下一個最簡單的單例類的實現。
#include "stdafx.h" #include <stdio.h> #include <iostream>using namespace std;class Singleton { public:static Singleton& GetInstance(){static Singleton instance_;return instance_;}~Singleton(){cout << "~Singleton" << endl;} public:Singleton(){cout << "Singleton " << endl;}Singleton(const Singleton &other);Singleton & operator=(const Singleton &other); };int _tmain(int argc, _TCHAR* argv[]) {Singleton& slt = Singleton::GetInstance();return 0; }轉載于:https://www.cnblogs.com/betterwgo/p/10372150.html
總結
- 上一篇: LOJ-10096(强连通+bfs)
- 下一篇: kafka命令使用