Solved

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

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to understand recursion 12 230
Compile GLUT with Visual Studio 2015 1 174
Dynamically allocate memory 9 63
How to gracefully close the c++ 11 thread? 3 108
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

828 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