📄 singleton.h
字号:
// Singleton.h: interface for the Singleton class.
//
//////////////////////////////////////////////////////////////////////
#ifndef __SINGLETON_H__
#define __SINGLETON_H__
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <assert.h>
#include <windows.h>
//
// 教臂沛狼 泅犁 荤侩篮 new 甫 救窍搁辑档
// 贸府窍绰 措秦急 祈窍瘤父
// Singleton 按眉 家戈俊 措秦急 包咯且 荐 绝嚼聪促.
// 疙矫利栏肺 阿 按眉付促 Release() 肺 舅竿捞父 朝府搁 登瘤父辑档
// 葛电 教臂畔捞 橇肺弊伐 牢胶畔胶啊 辆丰瞪锭鳖瘤
// 混酒乐阑鞘夸啊 绝阑锭档 乐阑芭扼 积阿 邓聪促.
// 酒贰狼 郴侩贸烦 窍绰扒 绢冻鳖夸?
namespace util
{
template <typename T>
class Singleton
{
public:
~Singleton()
{
}
static T * Instance()
{
if (0 == ms_pInstance)
{
ms_pInstance = new T;
}
return ms_pInstance;
}
static VOID DestroyInstance()
{
if (ms_pInstance) {
delete ms_pInstance;
ms_pInstance = NULL;
}
}
private:
static T * ms_pInstance;
};
// 疙矫利栏肺 檬扁拳 窍瘤臼酒档 0捞促
template< class T > T * Singleton<T>::ms_pInstance = 0;
}
#endif // __SINGLETON_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -