Solved

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

Posted on 2014-10-23
2
175 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: 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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

623 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