I am working on a programming project from the book I am learning c++ from.
I already have a base class and a derived class given to me (and they work properly, I checked). I am too make a derived class from the derived class.
The derived class I am working on is called Administrator, the class I am deriving it from is called SalariedEmployee.
I think my constructors are working correctly…Now, I have a simple main function that I am using trying to test my work so far.
Code:
#include <iostream>
#include <string>
#include "administrator.h"
using namespace std;
using namespace employeessavitch;
int main()
{
Administrator shane;
shane.set_supervisor();
//or shane.print() or shane.info_in()
return 0;
}
It compiles fine, but when I link I get the follow error:
Code:
5.obj : error LNK2001: unresolved external symbol "public: void __thiscall employeessavitch::Administrator::set_supervisor(void)"
(?set_supervisor@Administrator@employeessavitch@@QAEXXZ)
5.obj : error LNK2001: unresolved external symbol "public: __thiscall employeessavitch::Administrator::Administrator(void)"
(??0Administrator@employeessavitch@@QAE@XZ)
Debug/5.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
And I get the same error for any function I have created (but replaced with the name of that function in the error). And I have made sure that the other classes the variables are under ‘protected’ and not ‘private’.
Any ideas?
*edit* I just noticed I am also getting a linking error when I try and call the constructor that takes values).....
.h and .cpp from classes follow.
Administrator.h
Code:
#ifndef ADMINISTRATOR_H
#define ADMINISTRATOR_H
#include <string>
#include "salariedemployee.h"
using namespace std;
namespace employeessavitch
{
class Administrator : public SalariedEmployee
{
public:
Administrator();
Administrator(string the_title, string the_position, double the_salary /*weekly*/, string the_supervisor,
string the_name, string the_ssn );
void set_supervisor();
void info_in( );
void print();
void print_check();
protected:
string Title;
string Position;
string Supervisor;
};
}//empolyeessavitch
#endif
administrator.cpp
Code:
#include <string>
#include <iostream>
#include "administrator.h"
using namespace std;
namespace employeessavitch
{
Administrator::Administrator() : SalariedEmployee(), Title("N/A"), Position("N/A"), Supervisor("N/A")
{
//Left blank
}
Administrator::Administrator(string the_title, string the_position, double the_salary,
string the_supervisor, string the_name, string the_ssn) :
/* : */ SalariedEmployee(the_name, the_ssn, the_salary), Title(the_title), Position(the_position), Supervisor(the_supervisor)
{
//Left blank
}
void Administrator::set_supervisor()
{
string temp;
cout << "Enter the new supervisor's name: ";
cin >> temp;
Supervisor = temp;
}
void Administrator::info_in()
{
cout << "Enter the administrators title: ";
cin >> Title;
cout << "\nEnter the administrators position: ";
cin >> Position;
cout << "\nEnter the administrators weekly salary: ";
cin << salary;
}
void Administrator::print()
{
cout << "Output data to screen"; //finish later
}
void Administrator::print_check()
{
cout << "Output data in and info from base classes in check format"; //finish later
}
}//employeessavitch