1 Star 0 Fork 0

glm-001/shenntoufromgithub

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
singleton.h 523 Bytes
一键复制 编辑 原始数据 按行查看 历史
glm-001 提交于 2024-09-13 10:35 +08:00 . resetcodes
#ifndef SINGLETON_H
#define SINGLETON_H
template < class T >
class singleton
{
protected:
singleton(){};
private:
singleton( const singleton & ){};
singleton &operator =( const singleton & ){};
static T *m_instance;
public:
static T * GetInstance();
};
template <class T >
T * singleton< T >::GetInstance()
{
if ( m_instance==nullptr )
{
m_instance = new T();
}
return m_instance;
}
template < class T >
T * singleton< T >::m_instance = nullptr;
#endif // SINGLETON_H
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/glm-001/permeatefromgithub.git
git@gitee.com:glm-001/permeatefromgithub.git
glm-001
permeatefromgithub
shenntoufromgithub
main

搜索帮助