error LNK2001: unresolved external symbol
-
Hi! I need help with this problem, I got this error before but I managed to solve. But now I have a case with the virtual function. The source looks like this(after the code I continued writing): #include "stdafx.h" #ifndef EMPTRANSH #define EMPTRANSH #include "Global.h" #include "iostream" #include "string" using namespace std; class EmpTrans { private: int id; char emp_name[MAXNAMELENGTH]; employee_status emp_st; int salary; salary_type sal_st; char deal_date[DATELENGTH]; public: EmpTrans(); static void Open(); static void Close(); void ReadNext(); virtual void Apply(); void UpdateId(int i){id = i;} void UpdateSalary(int s){salary = s;} void UpdateEmployeeStatus(employee_status es){emp_st = es;} void UpdateSalaryType(salary_type ss){sal_st = ss;} void UpdateDate(char * d){strcpy(deal_date,d);} void UpdateEmployeeName(char en){emp_name[0] = en;} int GetId(){return id;} char * GetEmployeeName(){return emp_name;} employee_status GetEmployeeStatus(){return emp_st;} int GetSalary(){return salary;} salary_type GetSalaryType(){return sal_st;} char * GetDate(){return deal_date;} }; #endif class EmpTransAdd : public EmpTrans { public: void Apply(); }; class EmpTransChange : public EmpTrans { public: void Apply(); }; class EmpTransDelete : public EmpTrans { public: void Apply(); }; When I compile and link this source I get the error, when I remove the virtaul function from the Apply function, everything works fine. What is the problem? Do I need to take out the other classes from the source? or to include them inside the ifdef? Thanks :)
-
Hi! I need help with this problem, I got this error before but I managed to solve. But now I have a case with the virtual function. The source looks like this(after the code I continued writing): #include "stdafx.h" #ifndef EMPTRANSH #define EMPTRANSH #include "Global.h" #include "iostream" #include "string" using namespace std; class EmpTrans { private: int id; char emp_name[MAXNAMELENGTH]; employee_status emp_st; int salary; salary_type sal_st; char deal_date[DATELENGTH]; public: EmpTrans(); static void Open(); static void Close(); void ReadNext(); virtual void Apply(); void UpdateId(int i){id = i;} void UpdateSalary(int s){salary = s;} void UpdateEmployeeStatus(employee_status es){emp_st = es;} void UpdateSalaryType(salary_type ss){sal_st = ss;} void UpdateDate(char * d){strcpy(deal_date,d);} void UpdateEmployeeName(char en){emp_name[0] = en;} int GetId(){return id;} char * GetEmployeeName(){return emp_name;} employee_status GetEmployeeStatus(){return emp_st;} int GetSalary(){return salary;} salary_type GetSalaryType(){return sal_st;} char * GetDate(){return deal_date;} }; #endif class EmpTransAdd : public EmpTrans { public: void Apply(); }; class EmpTransChange : public EmpTrans { public: void Apply(); }; class EmpTransDelete : public EmpTrans { public: void Apply(); }; When I compile and link this source I get the error, when I remove the virtaul function from the Apply function, everything works fine. What is the problem? Do I need to take out the other classes from the source? or to include them inside the ifdef? Thanks :)
You don't provide a body for the EmpTrans::Open(), EmpTrans::Close(), EmpTrans::Apply functions (well at least you didn't show us). You still need to provide a body for those functions in the base class, unless they are pure virtual functions (e.g.
virtual void Apply() = 0;
), in which case it is mandatory that each child classes implement this function.Cédric Moonen Software developer
Charting control [v1.5] OpenGL game tutorial in C++ -
Hi! I need help with this problem, I got this error before but I managed to solve. But now I have a case with the virtual function. The source looks like this(after the code I continued writing): #include "stdafx.h" #ifndef EMPTRANSH #define EMPTRANSH #include "Global.h" #include "iostream" #include "string" using namespace std; class EmpTrans { private: int id; char emp_name[MAXNAMELENGTH]; employee_status emp_st; int salary; salary_type sal_st; char deal_date[DATELENGTH]; public: EmpTrans(); static void Open(); static void Close(); void ReadNext(); virtual void Apply(); void UpdateId(int i){id = i;} void UpdateSalary(int s){salary = s;} void UpdateEmployeeStatus(employee_status es){emp_st = es;} void UpdateSalaryType(salary_type ss){sal_st = ss;} void UpdateDate(char * d){strcpy(deal_date,d);} void UpdateEmployeeName(char en){emp_name[0] = en;} int GetId(){return id;} char * GetEmployeeName(){return emp_name;} employee_status GetEmployeeStatus(){return emp_st;} int GetSalary(){return salary;} salary_type GetSalaryType(){return sal_st;} char * GetDate(){return deal_date;} }; #endif class EmpTransAdd : public EmpTrans { public: void Apply(); }; class EmpTransChange : public EmpTrans { public: void Apply(); }; class EmpTransDelete : public EmpTrans { public: void Apply(); }; When I compile and link this source I get the error, when I remove the virtaul function from the Apply function, everything works fine. What is the problem? Do I need to take out the other classes from the source? or to include them inside the ifdef? Thanks :)
-
Hi! I need help with this problem, I got this error before but I managed to solve. But now I have a case with the virtual function. The source looks like this(after the code I continued writing): #include "stdafx.h" #ifndef EMPTRANSH #define EMPTRANSH #include "Global.h" #include "iostream" #include "string" using namespace std; class EmpTrans { private: int id; char emp_name[MAXNAMELENGTH]; employee_status emp_st; int salary; salary_type sal_st; char deal_date[DATELENGTH]; public: EmpTrans(); static void Open(); static void Close(); void ReadNext(); virtual void Apply(); void UpdateId(int i){id = i;} void UpdateSalary(int s){salary = s;} void UpdateEmployeeStatus(employee_status es){emp_st = es;} void UpdateSalaryType(salary_type ss){sal_st = ss;} void UpdateDate(char * d){strcpy(deal_date,d);} void UpdateEmployeeName(char en){emp_name[0] = en;} int GetId(){return id;} char * GetEmployeeName(){return emp_name;} employee_status GetEmployeeStatus(){return emp_st;} int GetSalary(){return salary;} salary_type GetSalaryType(){return sal_st;} char * GetDate(){return deal_date;} }; #endif class EmpTransAdd : public EmpTrans { public: void Apply(); }; class EmpTransChange : public EmpTrans { public: void Apply(); }; class EmpTransDelete : public EmpTrans { public: void Apply(); }; When I compile and link this source I get the error, when I remove the virtaul function from the Apply function, everything works fine. What is the problem? Do I need to take out the other classes from the source? or to include them inside the ifdef? Thanks :)
if you do not have implementation for
virtual void Apply()
in class EmpTrans, you should make it.virtual void Apply()=0
A pure virtual function,
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus