Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. error LNK2001: unresolved external symbol

error LNK2001: unresolved external symbol

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestioncareer
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    ytubis
    wrote on last edited by
    #1

    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 :)

    C S E 3 Replies Last reply
    0
    • Y ytubis

      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 :)

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      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++

      1 Reply Last reply
      0
      • Y ytubis

        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 :)

        S Offline
        S Offline
        S p k 521
        wrote on last edited by
        #3

        Will u pls show the code which creates the instance of ur class EmpTrans? you have to provide the definition of Apply() in the base class. else it have to be a pure virtual function.

        modified on Tuesday, March 24, 2009 6:44 AM

        1 Reply Last reply
        0
        • Y ytubis

          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 :)

          E Offline
          E Offline
          Eytukan
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups