c++单例模式实现

class noncopyable
{
public:
	noncopyable(const noncopyable&) = delete;
	noncopyable& operator=(const noncopyable&) = delete;
	noncopyable() = default;
	~noncopyable() = default;
};
template <class ValueType> 

class Singleton :public noncopyable
{ 
public:
	static ValueType& GetInstance()
	{
		static ValueType t; 
		return t;
	}
protected:
	Singleton() = default;
	~Singleton() = default;
};

  

posted on 2024-02-01 16:03  对我不好  阅读(1)  评论(0编辑  收藏  举报

导航