备忘 ^_^
.h 文件
Class OneWnd
{
private:
OneWnd(void);
~OneWnd(void);
static OneWnd* m_pInstance;
class CGarbo
{
public:
~CGarbo()
{
if (OneWnd::Instance())
{
// to do clear something…}
}
};
static CGarbo Garbo;
public:
static OneWnd* Instance();
}
.cpp文件
OneWnd* OneWnd::m_pInstance = NULL;
OneWnd* OneWnd::Instance()
{
if (m_pInstance == NULL )
{
m_pInstance = new OneWnd();
}
return m_pInstance;
}
以后不能忘了哈~~~
注:(2010-10-21)
Instance()方法里的 m_pInstance 这个值不能写成this->m_pInstance 会报错的哦