























template<typename T>
class Singleton {
public:
static T& GetInstance() {
static T instance;
return instance;
}
virtual ~Singleton() {
}
Singleton(const Singleton&) = delete;
Singleton& operator =(const Singleton&) = delete;
protected:
Singleton() {
}
};
用法
class Config : public Singleton<Config>
{
friend class Singleton<Config>;
public:
Config();
~Config();
};
本文版权归作者所有,欢迎转载,但必须给出原文链接,并保留此段声明,否则保留追究法律责任的权利。
posted @ 2024-04-16 08:51 StationaryTraveller 阅读(36) 评论(0) 收藏 举报
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。