Unresolved External Symbol is Unresolved
Hi all, I'm getting the below error in the below code. What am I doing wrong?
LNK2001
unresolved external symbol "public: static char const DateProfile::GENDER_MALE_UP" (?GENDER_MALE_UP@DateProfile@@2DB)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#include <iostream>
#include <ctime>
#include <sstream>
using namespace std;
class DateProfile
{
private:
char gender;
public:
static const char GENDER_MALE_UP;
static const char GENDER_MALE_LOW;
bool setGender(char gen);
char getGender() { return gender; };
};
char const GENDER_MALE_UP = 'M';
char const GENDER_MALE_LOW = 'm';
int main()
{
return 0;
}
bool DateProfile::setGender(char gen)
{
if (gen == GENDER_MALE_LOW || gen == GENDER_MALE_UP)
{
gender = gen;
return true;
}
else
return false;
}
|
Change the definitions to:
1 2
|
char const DateProfile::GENDER_MALE_UP = 'M';
char const DateProfile::GENDER_MALE_LOW = 'm';
|
I did that, and it worked. Thanks for the fix!
Could you tell me why I needed to add the class?
Because the variables are class members, you were creating separate variables.
That makes total sense. Thanks! I appreciate the troubleshooting and the lesson
Topic archived. No new replies allowed.