Code:
Hi everyone,
Can someone please review this for me I think I'm doing everything right but every time I try to compile I get an error message saying fatal error C1083 this is my code:
//program to test employee class
#include<iostream.h>
#include<string.h>
#include"Employee.h"
#include"Staff.h"
#include"Faculty.h"
void main(void){
Employee *e;
Staff s;
Faculty f;
s.setFirst_name("Eric"); //set first & last name and salary
s.setLast_name("Jones");
s.setsalary(50000.00);
e=&s;
//Print out name and monthly salary for salary employee
cout<<"The staff individual's first name is: "<<e->getFirst_name()<<endl;
cout<<"The staff individual's last name is: "<<e->getLast_name()<<endl;
cout<<"The staff individual's pay is: "<<e->compute_monthly_pay()<<endl;
//Print out name and monthly salary for hourly employee
f.setFirst_name("Mary"); //set first & last name and salary
f.setLast_name("Smith");
f.sethourly_rate(50.00);
e = &f;
cout<<"The faculty individual's first name is: "<<e->getFirst_name()<<endl;
cout<<"The faculty individual's last name is: "<<e->getLast_name()<<endl;
cout<<"The faculty individual's pay is: "<<e->compute_monthly_pay()<<endl;
}
//Faculty class
#include "Employee.h"
class Faculty : public Employee
{
public:
float compute_monthly_pay();
Faculty();
virtual ~Faculty();
void sethourly_rate(float); //set salary
float gethourly_rate();
protected:
float hourly_rate;
};
Faculty::Faculty()
{
}
Faculty::~Faculty()
{
}
void Faculty::sethourly_rate(float h_r) //set hourly rate
{
hourly_rate = h_r ;
}
float Faculty::gethourly_rate()
{
return hourly_rate;
};
float Faculty::compute_monthly_pay() //compute pay
{
return (hourly_rate*160);
}
//Employee class
#include<string.h>
class Employee {
private:
char* First_name;
char* Last_name;
public:
virtual float compute_monthly_pay(void) = 0;
Employee(); //default constructor
~Employee(); // default destructor
const char* getFirst_name()const;
const char* getLast_name()const;
void setFirst_name(char*); //set first name
void setLast_name(char*); //set last name
};
Employee::Employee()
{
}
Employee::~Employee() //delete first and last name
{
delete[] First_name;
delete[] Last_name;
}
const char* Employee::getFirst_name() const
{
return First_name;
}
void Employee::setFirst_name(char* fn) //set first name
{
First_name = new char[strlen(fn) + 1];
strcpy(First_name,fn);
}
void Employee::setLast_name(char* ln) //set last name
{
Last_name = new char[strlen(ln) + 1];
strcpy(Last_name, ln);
}
const char* Employee::getLast_name()const
{
return Last_name;
}
//Staff class
#include "Employee.h"
class Staff : public Employee
{
public:
float compute_monthly_pay();
Staff();
virtual ~Staff();
void setsalary(float); //set salary
float getsalary();
// float compute_monthly_pay();
protected:
float salary;
};
#include "Staff.h"
Staff::Staff()
{
}
Staff::~Staff()
{
}
void Staff::setsalary(float sal)
{
salary = sal;
}
float Staff::getsalary()
{
return salary;
};
float Staff::compute_monthly_pay()
{
return (salary/12);
}
cut him a little slack, notice he has only 3 posts, and probably doesn't know how to use code tags