Solved

error LNK2001: unresolved external symbol "public: static bool A::myvar" (?myvar@A@@2_NA)

Posted on 2014-10-23
2
170 Views
Last Modified: 2014-10-23
I'm not clear on why I get that error on this piece of code:

#include "stdafx.h"

class A {
public:
      static bool myvar;
};

int _tmain(int argc, _TCHAR* argv[])
{
      A::myvar = true;
      return 0;
}

Thanks!
0
Comment
Question by:rustycp
2 Comments
 
LVL 14

Accepted Solution

by:
brendanmeyer earned 500 total points
ID: 40400907
#include "stdafx.h"

class A {
public:
      static bool myvar;
};

bool A::myvar;


int _tmain(int argc, _TCHAR* argv[])
{
      A::myvar = true;
      return 0;
}

Open in new window


you have declared the bool, but didn't define it. (added line 8)
0
 
LVL 2

Author Comment

by:rustycp
ID: 40400925
ok simple enough...thx!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

733 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