I have the files of my program as following:
main.cpp
employee.cpp
fullTime.cpp
partTime.cpp
employee.h
fulltime.h
partTime.h
I've got so much link errors of this program.
What's the problem of them?
Thanks for anyone's help!!
+++++++++++++++++++++++++++++++++++++++++++++
main.cpp
---------
#include <iostream.h>
#include <string.h>
#include "Employee.h"
#include "fullTime.h"
#include "partTime.h"
void main()
{
Employee* emploPtr[2];
Employee e("Johnny", 40000);
fullTime *ft = new fullTime("John", 30000, 10);
fullTime ft1("Dr. John", 50000, 20);
partTime pt("Patrick", 5000, 300, 100);
emploPtr[0]=&e;
emploPtr[1]=&pt;
for ( int i = 0; i < 2; i++)
if (emploPtr[i] -> calculateSalary() <= 40000)
emploPtr[i]->printAll();
cout << endl;
ft->calculateSalary();
ft->printAll();
cout << endl;
ft1.calculateSalary();
ft1.printAll();
}
+++++++++++++++++++++++++++++++++++++++++++++
employee.cpp
---------
#include<iostream.h>
#include<string.h>
#include"Employee.h"
Employee::Employee(char* N="", float sal=0)
{
strcpy(Name,N);
salary=sal;
}
char* Employee::getName()
{
return Name;
}
float Employee::calculateSalary()
{
return salary;
}
void Employee:rintAll()
{
cout<<"Name :"<<Name<<endl;
cout<<"Salary :"<<salary<<endl;
}
+++++++++++++++++++++++++++++++++++++++++++++
fullTime.cpp
---------
include<iostream.h>
#include<string.h>
#include"Employee.cpp"
#include"fullTime.h"
fullTime::fullTime(char *N, float sal, int y):Employee(N, sal)
{
year=y;
}
float fullTime::calculateSalary()
{
if(year>15)
salary =salary *2/10 +salary;
else
salary =salary *1/10 +salary;
return salary;
}
void fullTime:rintAll()
{
Employee:rintAll();
cout<<"Employee worked year : "<<year<<endl;
}
+++++++++++++++++++++++++++++++++++++++++++++
partTime.cpp
---------
#include<iostream.h>
#include<string.h>
#include"Employee.cpp"
#include"partTime.h"
partTime:artTime(char *N, float sal, float pay, int h):Employee(N, sal)
{
hourlyPay=pay;
hours=h;
}
float partTime::calculateSalary()
{
salary=salary+hours*hourlyPay;
return salary;
}
void partTime:rintAll()
{
Employee:rintAll();
cout<<"Working hours : "<<hours<<endl;
cout<<"Hourly pay :"<<hourlyPay<<endl;
}
+++++++++++++++++++++++++++++++++++++++++++++
employee.h
---------
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
class Employee
{
public:
Employee(char* N, float);
char* getName();
float calculateSalary();
void printAll();
protected:
char* Name;
float salary;
};
#endif
+++++++++++++++++++++++++++++++++++++++++++++
fulltime.h
---------
#ifndef FULLTIME_H
#define FULLTIME_H
#include "Employee.h"
class fullTime: private Employee
{
public:
float calculateSalary();
void printAll();
fullTime(char*, float, int);
private:
int year;
};
#endif
+++++++++++++++++++++++++++++++++++++++++++++
partTime.h
---------
#ifndef PARTTIME_H
#define PARTTIME_H
class partTime: public Employee
{
public:
float calculateSalary();
void printAll();
partTime(char*, float, float, int);
private:
float hourlyPay;
int hours;
};
#endif