![]() |
Unresolved external symbol in class
I can't get this to compile what am i doing wrong. This is just a simple class that represents dates (month day yr). I have a feeling what i am doing wrong has to do with the mynames portion both in date.h and date.cpp.
error Code:
1>date.obj : error LNK2001: unresolved external symbol "private: static char * * date::mnames" (?mnames@date@@0PAPADA)date.h Code:
#pragma onceCode:
#include <iostream> |
Re: Unresolved external symbol in class
If static char *mnames[]; relates to static char *mnames[]= { "Jan",..., then the problem is that you need to declare the latter as date::mnames, not just mnames.
|
Re: Unresolved external symbol in class
i changed it to
Code:
static char *date::mnames[]= { "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sep", "Oct", "Nov", "Dec" };Code:
error C2720: 'date::mnames' : 'static ' storage-class specifier illegal on membersCode:
1>employee.obj : error LNK2019: unresolved external symbol "public: __thiscall date::date(class date &)" (??0date@@QAE@AAV0@@Z) referenced in function "public: class date __thiscall Employee::getHireDate(void)" (?getHireDate@Employee@@QAE?AVdate@@XZ)employee.h Code:
#pragma onceCode:
#include "employee.h" |
Re: Unresolved external symbol in class
1. removing "static" (on the static member's definition in date.cpp) was the correct thing to do.
2. This is a completely different error. You forgot to implement "data::date(date &)" in data.cpp (although it is in date.h). |
Re: Unresolved external symbol in class
Yep, sorry about that, oogabooga's right, static isn't needed. One day I'll learn to compile it first...
What errors do you get for the employee class? |
Re: Unresolved external symbol in class
Quote:
What do i put in the body for date(date &) i have no clue what to put here. |
Re: Unresolved external symbol in class
Normally you would copy the members across from the parameter; this is a copy constructor.
Code:
date::date(date &d) |
Re: Unresolved external symbol in class
Thank you, it compiles :)
|
| All times are GMT +5.5. The time now is 19:59. |