class Singleton
{
public:
static Singleton* getInstance()
{
static Singleton instance;
return &instance;
}
private:
Singleton(){}
~Singleton(){std::cout<<"~Singleton()\n";}
Singleton(const Singleton &)=delete;
Singleton& operator=(const Singleton &)=delete;
Singleton(Singleton &&)=delete;
Singleton& operator=(Singleton &&)=delete;
};
线程安全的单例模式(c++实现)
于 2024-08-24 13:05:32 首次发布