[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

error lnk2001: unresolved external symbol

Posted on 2006-05-05
2
Medium Priority
?
303 Views
Last Modified: 2010-04-17
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?
0
Comment
Question by:hybrid79
1 Comment
 
LVL 32

Accepted Solution

by:
jhance earned 150 total points
ID: 16613258
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Simple Linear Regression

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question