Employee parttime employee program C++

I never had c++, but i am in a program debbuing class that uses C++. I am not good with inheritance and class etc. I am having trouble debuing the following can someone please help..Thanks

// DEBUG10-4
// PartTimeEmployee derives from Employee
/ Employees make $800 per week
// PartTimeEmployees make $7.85 per hour
#include<iostream>
#include<string>
using namespace std;
class Employee
{
protected:
string firstName;
string lastName;
double salary;
public:
Employee(string, string);
void showEmployee();
void setData();
string getfirstName();
string getlastName();
};
Employee::Employee(string first, string last)
{
firstName = lasName;
lastName = lastName;
salary = 800;
}
void Employee::setData()
{
cout<<"Enter Employee's first name ";
cin>>frstName;
cout<<"Enter last name ";\
cin>lastName;
salary = 800;
void Employee::showEmployee()
{
cout<<firstName<<" "<<lastName<<
" Salary $"<<salary<<endl;
}
string Employee::getlastName()
{
return lstName;
}
string Employee::getfirstName()
{
return first
}
class : PartTimeEmployee : public : Employee
{
public:
PartTimeEmployee(string, string);
};
PartTimeEmployee::PartTimeEmployee(string first, string last) :
Employee(first,lst)
{
salary = 7.85;
}

int main()
{
const int NUMEMPS = 10;
Employee workers[NUMEMPS];
int x;
for(x = 0; x < NUMEMPS; ++x)
{
Employee temp;
char pt;
temp.setData();
cout<<"Is employee part time - y or n? ";
cin>>pt;
if(pt = 'y')
{
PartTimeEmployee tempPartTime(temp.getfirstName(), temp.getlastName());
temp = tempPartTime;
}
workers[y] = temp;
}
cout<<endl<<"Employees: "<<endl;
for(x = 0; x <= NUMEMPS; ++x)
workers[NUMEMPS].showEmployee();
}
So, your assignment is to find the bug?

Here it is in [code][/code] tags:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// DEBUG10-4
// PartTimeEmployee derives from Employee
/ Employees make $800 per week
// PartTimeEmployees make $7.85 per hour
#include<iostream>
#include<string>
using namespace std;
class Employee
{
protected:
  string firstName;
  string lastName;
  double salary;
public:
  Employee(string, string);
  void showEmployee();
  void setData();
  string getfirstName();
  string getlastName();
};
Employee::Employee(string first, string last)
{
  firstName = lasName;
  lastName = lastName;
  salary = 800;
}
void Employee::setData()
{
  cout<<"Enter Employee's first name ";
  cin>>frstName;
  cout<<"Enter last name ";\
  cin>lastName;
  salary = 800;
void Employee::showEmployee()
{
  cout<<firstName<<" "<<lastName<<
  " Salary $"<<salary<<endl;
}
string Employee::getlastName()
{
  return lstName;
}
string Employee::getfirstName()
{
  return first
}
class : PartTimeEmployee : public : Employee
{
public:
  PartTimeEmployee(string, string);
};
PartTimeEmployee::PartTimeEmployee(string first, string last) :
Employee(first,lst)
{
  salary = 7.85;
}

int main()
{
  const int NUMEMPS = 10;
  Employee workers[NUMEMPS];
  int x;
  for(x = 0; x < NUMEMPS; ++x)
  {
    Employee temp;
    char pt;
    temp.setData();
    cout<<"Is employee part time - y or n? ";
    cin>>pt;
    if(pt = 'y')
    {
      PartTimeEmployee tempPartTime(temp.getfirstName(), temp.getlastName());
      temp = tempPartTime;
    }
    workers[y] = temp;
  }
  cout<<endl<<"Employees: "<<endl; 
  for(x = 0; x <= NUMEMPS; ++x)
    workers[NUMEMPS].showEmployee();
}


You've either recopied it poorly or it has a lot of issues. It currently won't even compile.
I copied it from a text file.
This is it exactly from the text file.

// DEBUG10-4
// PartTimeEmployee derives from Employee
/ Employees make $800 per week
// PartTimeEmployees make $7.85 per hour
#include<iostream>
#include<string>
using namespace std;
class Employee
{
protected:
string firstName;
string lastName;
double salary;
public:
Employee(string, string);
void showEmployee();
void setData();
string getfirstName();
string getlastName();
};
Employee::Employee(string first, string last)
{
firstName = lasName;
lastName = lastName;
salary = 800;
}
void Employee::setData()
{
cout<<"Enter Employee's first name ";
cin>>frstName;
cout<<"Enter last name ";\
cin>lastName;
salary = 800;
void Employee::showEmployee()
{
cout<<firstName<<" "<<lastName<<
" Salary $"<<salary<<endl;
}
string Employee::getlastName()
{
return lstName;
}
string Employee::getfirstName()
{
return first
}
class : PartTimeEmployee : public : Employee
{
public:
PartTimeEmployee(string, string);
};
PartTimeEmployee::PartTimeEmployee(string first, string last) :
Employee(first,lst)
{
salary = 7.85;
}

int main()
{
const int NUMEMPS = 10;
Employee workers[NUMEMPS];
int x;
for(x = 0; x < NUMEMPS; ++x)
{
Employee temp;
char pt;
temp.setData();
cout<<"Is employee part time - y or n? ";
cin>>pt;
if(pt = 'y')
{
PartTimeEmployee tempPartTime(temp.getfirstName(), temp.getlastName());
temp = tempPartTime;
}
workers[y] = temp;
}
cout<<endl<<"Employees: "<<endl;
for(x = 0; x <= NUMEMPS; ++x)
workers[NUMEMPS].showEmployee();
}
I want to apologise to all for not posting the code in proper format, using code tags etc. I just did some research on proper posting..
Can anyone help me with this?
What is your assignment? What are you stuck on? What exactly do you want from us?

We're not magical machines that you input code, think what you want, and we read your mind and give you want you want ;)

Also, you can edit your posts by clicking the edit button (make sure you don't accidentally click "report")
Topic archived. No new replies allowed.