LInk errors

This is a discussion on LInk errors within the C++ Programming forums, part of the General Programming Boards category; If anybody knows about these errors will you please help me with them? The errors I get are: 1>Week6iLab.obj : ...

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    4

    LInk errors

    If anybody knows about these errors will you please help me with them? The errors I get are:

    1>Week6iLab.obj : error LNK2001: unresolved external symbol "public: virtual double __thiscall Employee::wages(void)const " (?wages@Employee@@UBENXZ)

    1>Week6iLab.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall Employee:rint(void)const " (?print@Employee@@UBEXXZ)

    1>C:\Users\nglwthnati2de\Documents\Visual Studio 2008\Projects\Week6iLab_RWilson\Debug\Week6iLab_RW ilson.exe : fatal error LNK1120: 2 unresolved externals

    Now this code isn't completed yet. I just like to keep a handle on my stuff as I go along. Here is my code:

    Code:
    #include <iostream>
    #include <string>
    #include <iomanip>
    using namespace std;
    
    class Employee
    {
    public:
    	Employee(const string &, const string &, const string &);
    
    	void setFirstName(const string &);
    	string getFirstName()const;
    
    	void setLastName(const string &);
    	string getLastName()const;
    
    	void setEmployeeID(const string &);
    	string getEmployeeID()const;
    
    	virtual double wages()const;
    	virtual void print()const;
    private:
    	string firstName;
    	string lastName;
    	string employeeID;
    };
    
    class Manager : public Employee
    {
    public:
    	Manager(const string &, const string &, const string &, double = 0.0);
    
    	void setWeeklySalary(double);
    	double getWeeklySalary()const;
    
    	virtual void print()const;
    private:
    	double weeklySalary;
    };
    
    class EntryLevelEmployee : public Employee
    {
    	EntryLevelEmployee(const string &, const string &, const string &, double = 0.0, double = 0.0);
    	
    	void setHourlyPay(double);
    	double getHourlyPay()const;
    
    	void setHours(double);
    	double getHours()const;
    
    	virtual double earnings()const;
    	virtual void print()const;
    private:
    	double pay;
    	double hours;
    };
    
    class SalesRep : public Employee
    {
    public:
    	SalesRep(const string &, const string &, const string &, double = 0.0, double = 0.0);
    
    	void setCommissionRate(double);
    	double getCommissionRate()const;
    
    	void setTotalSales(double);
    	double getTotalSales()const;
    
    	virtual double earnings()const;
    	virtual void print()const;
    private:
    	double totalSales;
    	double commissionRate;
    };
    
    class SalesManager : public SalesRep
    { 
    public:
    	SalesManager(const string &, const string &, const string &, double = 0.0, double = 0.0, double = 0.0);
    
    	void setBaseSalary(double);
    	double getBaseSalary()const;
    
    	virtual double earnings()const;
    	virtual void print()const;
    private:
    	double baseSalary;
    };
    
    //class definitions
    
    Employee::Employee(const string &first, const string &last, const string &empID)
    : firstName (first),  lastName(last), employeeID(empID)
    {
    
    }
    
    int main()
    {
    	return 0;
    }

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    That's a little bit surprising, since I wouldn't expect those functions to be needed unless they were called (and I don't see you calling anything yet). If you just put a dummy function (i.e., like you did with Employee::Employee, with nothing inside the curly braces) does that fix the problem?

  3. #3
    Registered User
    Join Date
    Nov 2010
    Posts
    4
    Hmmm...not sure but I will try that out.
    Thanks for the tip.

  4. #4
    Registered User
    Join Date
    Dec 2010
    Posts
    2
    The virtual function definition is needed for vtable initialization. So better add a dummy definition to make compiler happy.


    -Raj
    Last edited by Salem; 12-08-2010 at 11:12 PM. Reason: Snip fake sig

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. stack error occured in link list
    By mycount in forum C Programming
    Replies: 5
    Last Post: 07-11-2006, 09:03 PM
  2. Multi link errors
    By swgh in forum C++ Programming
    Replies: 4
    Last Post: 01-31-2006, 04:20 PM
  3. Winsock compilation errors
    By jmd15 in forum Networking/Device Communication
    Replies: 2
    Last Post: 08-03-2005, 08:00 AM
  4. executing errors
    By s0ul2squeeze in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2002, 12:43 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21