Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-10-23
2
Medium Priority
?
192 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 2000 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

Independent Software Vendors: 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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

772 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