template<typename T>
class Singleton
{
public:
static T& getInstance() {
static T t;
return t;
}
Singleton(const Singleton&) = delete;
Singleton& operator=(const Singleton&) = delete;
protected:
Singleton() = default;
~Singleton() = default;
};
C++11 后的单例写法
发布时间 2023-11-27 11:21:10作者: penuel