https://www.cnblogs.com/didiaoxiaoguai/p/11661471.html
#include <iostream>
using namespace std;
class Singleton
{
public:
static Singleton& Instance()
{
static Singleton theSingleton;
return theSingleton;
}
void doSomeThong();
private:
Singleton();
~Singleton();
};
Singleton::Singleton()
{
}
Singleton::~Singleton()
{
}
void Singleton::doSomeThong()
{
cout << "单例类" << endl;
cout << "C++最推荐的单例类写法" << endl;
}
int main()
{
Singleton::Instance().doSomeThong();
return 0;
}