代码如下:
template <class T>
class Singleton
{
public:
static T* Instance()
{
if (m_instance == NULL)
{
m_instance = new T;
}
return m_instance;
}
private:
static T* m_instance;
};
class test :public Singleton<test>
{
}
编译时出现链接错误:Error 1 error LNK2001: unresolved external symbol "private: static class MyPragma * Singleton<class MyPragma>::m_instance" (?m_instance@?$Singleton@VMyPragma@@@@0PAVMyPragma@@A) SingletonTest.obj
各位大大们来看下这是什么一个情况?