标签:
class Singleton
{
public:
static Singleton * getInstance();
private:
Singleton();
~Singleton();
static Singleton * m_sglton ;//(此处也可直接写为静态变量)
};
Singleton* Singleton:: m_sglton = NULL;
- Singleton *Singleton::getInstance()
{
if(m_sglton == NULL)
{
m_sglton = new Singleton; //注意这一句
}
return sglton;(返回对象)
}
标签:
原文地址:http://www.cnblogs.com/chengkeke/p/5417369.html