error lnk2001: unresolved external symbol

I have a class with the following code. It is one of the classes in my project that i'm trying to compile into a dll.

class myClass
{
public:
      myClass();
      ~myClass();
      static myClass* getInstance();
private:
      static myClass* ptr;
}

When I try to compile it, I get this error lnk 2001: unresolved external symbol "private: static class myClass* myClass::ptr(ptr@myClass@@0PAV1@A)

Can anyone help with this?
hybrid79Asked:
Who is Participating?
 
jhanceConnect With a Mentor Commented:
Two things:

1) Add the ";" after your class.
2) You must initialize the static member variable in the global namespace.

class myClass
{
public:
      myClass();
      ~myClass();
      static myClass* getInstance();
private:
      static myClass* ptr;
};

myClass * myClass::ptr = NULL;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.