Solved

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

Posted on 2014-10-23
2
163 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

705 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now