最近在看单例设计模式从网上找了一个例子
class Singleton
{
private:
static Singleton* m_lpInstance;
Singleton(){};
public:
static Singleton *GetInstance()
{
if (NULL == m_lpInstance)
{
m_lpInstance = new Singleton();
}
return m_lpInstance;
}
};
main
{
Singleton *p1 = Singleton::GetInstance();
}
编译发现报错:
1>singletonModle.obj : error LNK2001: 无法解析的外部符号 "private: static class Singleton * Singleton::m_lpInstance" (?m_lpInstance@Singleton@@0PAV1@A)
1>E:\project\singletonModle\Debug\singletonModle.exe : fatal error LNK1120: 1 个无法解析的外部命令