Error LNK2001 无法解析的外部符号 的几种情况及解决办法
多线程下的单例模式
这里要处理的是懒汉模式。
[cpp]
view plain
copy
class Singleton { private: static Singleton* m_instance; Singleton(){} public: static Singleton* getInstance(); }; Singleton* Singleton::getInstance() { if(NULL == m_instance) { m_instance = new Singleton; } return m_instance; }
Error LNK2001 无法解析的外部符号
解决方法:
把static Singleton* m_instance;移动到类的头文件中类定义尾部。