I have produced this C++ code:
class TestInstance
{
public:
TestInstance();
~TestInstance();
static TestInstance& GetInstance();
private:
static TestInstance* testInstance;
};
But I got this error when compiling:
error LNK2001: unresolved external symbol “private: static class
TestInstance* TestInstance::testInstance”
(?testInstance@TestInstance@@0PAV1@A)fatal error LNK1120: 1 unresolved externals
Any idea?
Yes, initialize the
staticmember in an implementation file.