I am getting some errors in my program while trying to link two header files for my program and don't know why or what they mean..
Here are the errors:
- error LNK2019: unresolved external symbol "public: __thiscall EmployeeWithBankAccount::EmployeeWithBankAccount(class std::basic_string<char,struct std::char_traits<char>
- error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Employee::get_name(void)const "
- fatal error LNK1120: 2 unresolved externals
Heres the code with the two header files at the top:
#ifndef CCC_EMPL_H
#define CCC_EMPL_H
#include <string>
usingnamespace std;
/**
A basic employee class that is used in many examples
in the book "Computing Concepts with C++ Essentials"
*/
class Employee
{
public:
/**
Constructs an employee with empty name and no salary.
*/
Employee();
/**
Constructs an employee with a given name and salary.
@param employee_name the employee name
@param initial_salary the initial salary
*/
Employee(string employee_name, double initial_salary);
/**
Sets the salary of this employee.
@param new_salary the new salary value
*/
void set_salary(double new_salary);
/**
Gets the salary of this employee.
@return the current salary
*/
double get_salary() const;
/**
Gets the name of this employee.
@return the employee name
*/
string get_name() const;
private:
string name;
double salary;
};
#endif
I don't know if this is why, but you're inheriting EmployeeWithBankAccount and acting as if it has Employee's private members.
You don't inherit private members, if you want to inherit private members you must make them protected members so they remain encapsulated but still get inherited.