//administrator.cpp
#include <iostream>
#include <string>
#include "administrator.h"
using std::string;
using std::cin;
using std::cout;
namespace SavitchEmployees
{
Administrator::Administrator( ):Employee(), salary(0)
{
//deliberately empty
}
Administrator::Administrator(string theName, string theSsn, double theAnnualSalary)
:Employee(theName, theSsn),salary(theAnnualSalary)
{
//deliberately empty
}
void Administrator::inputAdminData()
{
cout << " Enter the details of the administrator " << getname() << endl;
cout << " Enter the admin title" << endl;
getline(cin, adminTitle);
cout << " Enter the area of responsibility " << endl;
getline(cin, workingArea);
cout << " Enter the immediate supervisor's name " << endl;
getline(cin, supervisorName);
}
void Administrator::outputAdminData()
{
cout << "Name: " << getname() << endl;
cout << "Title: " << adminTitle << endl;
cout << "Area of responsibility: " << workingArea << endl;
cout << "Immediate supervisor: " << supervisorName << endl;
}
void Administrator::printCheck()
{
setNetPay(salary);
cout << "\n___________________________________\n"
cout << "Pay to the order of " << getName() << endl
cout << "The sum of" << getNetPay() << "Dollars\n"
cout << "______________________________________\n"
<< "Check Stub Not negotiable \n"
cout << "Employee Number: " << getSsn() << endl
cout << "Salaried Employee(Administrator). Regular Pay: "
<< salary << endl
cout << "______________________________________\n";
}
}//SavitchEmployees
||=== employee, Debug ===|
obj\Debug\usingemployee.o||In function `main':|
D:\C++\employee\usingemployee.cpp|16|undefined reference to `SavitchEmployees::Administrator::Administrator(std::string, std::string, double)'|
D:\C++\employee\usingemployee.cpp|17|undefined reference to `SavitchEmployees::Administrator::inputAdminData()'|
D:\C++\employee\usingemployee.cpp|18|undefined reference to `SavitchEmployees::Administrator::outputAdminData()'|
D:\C++\employee\usingemployee.cpp|19|undefined reference to `SavitchEmployees::Administrator::printCheck()'|
||=== Build finished: 4 errors, 0 warni[/center]ngs ===|
Can someone tell me what is wrong with this code?
I think it is because of my administrator class, but after reading the code for more than half an hour, I still dunt get it.
Sorry if the code is too long...
Thank you very much!!!
Administrator inherits from SalariedEmployee [ class Administrator : public SalariedEmployee ], so the Constructor initialization list should be that of SalariedEmployee and not Employee.
edit:
There are some other issues with administrator.cpp,
missing: using std::endl;
getname() instead of getName()
printCheck() needs some ; anding the ends of some of the lines.
but generally administrator.cpp is not compiling so there is not object file for the linker to link to, hence the undefined reference to errors.
How are you building (compiling/linking) the code? Do you use an IDE or Command line tools? What tools to you use?
The likelihood is that for some reason compiling administrator.cpp is failing or possibly that linking to the object code of administrator.cpp is not setup.
Im using Code::block to build and I just got the problem solved. For some reasons, I didnt put my files inside the project file. After putting the files all in the file, the programme works well.
Thank you:)
But I cant understand why before adding the administrator file, it works well and does not have any linking problem. Previously the files were not in the project file as well.