CLASS inheritance....GOING LOCO!!!!!

C++ ....CLASS inheritance.... why am I getting this one error in my code???? it is driving me CRAZY!!!!!! PLEASE HELP....going loco!!!
sleep deprived + suck at this + is it over yet? + Jesus take the wheel.

​=======ERROR MESSAGE FROM THE COMPILER ========
||=== Build file: "no target" in "no project" (compiler: unknown) ===|
C:\ clases.cpp|22|error: expected unqualified-id before 'public'|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <cstdlib>

using namespace std;

#ifndef FIREEMPLOYEE_H
#define FIREEMPLOYEE_H

class employeeType public:personType
{
    private:
       int id;
       string first;
       string last;
       char gender;
       double payrate;
       string jobRole;
       int years;

    public:
    virtual void print() const = 0;
    //Function to output employee's data.
    virtual double calculatePay() const = 0;

    //Function to calculate and return the wages.
    //Postcondition: Pay is calculated and returned
    void setId(int personId)
    {
        personId = id;
    }
    //Function to set the salary.
    //Postcondition: personId = id;
    int getId() const
    {
        return id;
    }
    //Function to retrieve the id.
    //Postcondition: returns personId
    employeeType(string first = "", string last = "", long id = 0);
    //Constructor with parameters
    //Sets the first name, last name, payRate, and
//hoursWorked according to the parameters. If
//no value is specified, the default values are
//assumed.
//Postcondition: firstName = first;
                //lastName = last; personId = id;

};
#endif
//The definitions of the constructor and functions of the class
//employeeType that are not pure virtual are

/*void employeeType::setId(int personId)
    {
        personId = id;
    }   */
/*int employeeType::getId() const
    {
        return personId;
    }   */
employeeType::employeeType(string firstName, string lastName, long personId)
             //:personType(first, last)
    {
        firstName = first;
        lastName = last;
        personId = id;
    }

//#include "employeeType.h"
///============================================================================
class HireEmployee: public employeeType
{
public:
    void set(string first, string last, long id,
            double salary, double bonus);
//Function to set the first name, last name,
//id, and salary according to the parameters.
//Postcondition: firstName = first; lastName = last;
              // personId = id; empSalary = salary;
                //empBonus = bonus;

    void setSalary(double salary);
//Function to set the salary.
//Postcondition: empSalary = salary;
    double getSalary();
//Function to retrieve the salary.
//Postcondition: returns empSalary
    void setBonus(double bonus);
//Function to set the bonus.
//Postcondition: empBonus = bonus;
    double getBonus();
//Function to retrieve the bonus.
//Postcondition: returns empBonus;
    void print() const;
//Function to output the first name, last name,
//and the wages.
//Postcondition: Outputs
        //Id:
        //Name: firstName lastName
        //Wages: $$$$.$$
    double calculatePay() const;
    //Function to calculate and return the wages.
    //Postcondition: Pay is calculated and returned
HireEmployee(string first = "", string last = "",
                 long id = 0, double salary = 0, double bonus = 0);
//Constructor with default parameters.
//Sets the first name, last name, id, salary, and
//bonus according to the parameters. If
 //no value is specified, the default values are
 //assumed.
//Postcondition: firstName = first; lastName = last;
                //personId = id; empSalary = salary;
                //empBonus = bonus;

private:
    double empSalary;
    double empBonus;

};

//The definitions of the constructor and functions of the class HireEmployee are:

void HireEmployee::set(string first, string last,
                       long id,
                       double salary, double bonus)
{
    string setName;
    setName =  first + last;
    setId(id);
    empSalary = salary;
    empBonus = bonus;
}
void HireEmployee::setSalary(double salary)
{
    empSalary = salary;
}
double HireEmployee::getSalary()
{
    return empSalary;
}
void HireEmployee::setBonus(double bonus)
{
    empBonus = bonus;
}
double HireEmployee::getBonus()
{
    return empBonus;
}
void HireEmployee::print() const
{
    cout << "Id: " << getId() << endl;
    cout << "Name: "; personType::print();
    cout << endl;
    cout << "Wages: $" << calculatePay() << endl;
}
double HireEmployee::calculatePay() const
{
    return empSalary + empBonus;
}
HireEmployee::HireEmployee(string first, string last,
                                   long id, double salary,
                                   double bonus)
                 :employeeType(first, last, id)
{
    empSalary = salary;
    empBonus = bonus;
}
///============================================================================
//The definition of the class FireEmployee is:

//#include "employeeType.h"

class FireEmployee: public employeeType
{
public:
void set(string first, string last, long id,  ///void is good
            double rate, double hours);
//Function to set the first name, last name,
//id, payRate, and hoursWorked according to the parameters.
//Postcondition: firstName = first; lastName = last;
              // personId = id;
                //payRate = rate; hoursWorked = hours;

void calculatePay const
{
    return FirepayRate
}

//Function to calculate and return the wages.
//Postcondition: Pay is calculated and returne

void setFirepayRate(double FirepayRate)
{
    FirepayRate = rate;
}
//Function to set the salary.
//Postcondition: payRate = rate;

double getFirepayRate();
//Function to retrieve the salary.
//Postcondition: returns payRate;

void setHoursWorked(double hours);
//Function to set the bonus.
//Postcondition: hoursWorked = hours

double getHoursWorked();
//Function to retrieve the bonus.
//Postcondition: returns empBonus

void print() const;
//Function to output the id, first name, last name,
//and the wages.
//Postcondition: Outputs
        //Id:
        //Name: firstName lastName
        //Wages: $$$$.$$

FireEmployee(string first = "", string last = "",
                 long id = 0,
                 double rate = 0, double hours = 0);
//Constructor with parameters.
//Sets the first name, last name, payrate and
//hoursWorked according to the parameters. If
 //no value is specified, the default values are
 //assumed.
//Postcondition: firstName = first; lastName = last;
                //personId = id; payRate = rate;
                //hoursWorked = hours;

private:
    double FirepayRate;
    double hoursWorked;

};

//The definitions of the constructor and functions of the class FireEmployee are:

void FireEmployee::set(string first, string last,
                       long id,
                       double rate, double hours)
{
    string setName;
    setName =  first + last;
    setId(id);
    FirepayRate = rate;
    hoursWorked = hours;
}

void FireEmployee::setFirePayRate(double rate)
{
    FirepayRate = rate;
}

double FireEmployee::getFirePayRate()
{
    return FirepayRate;
}

void FireEmployee::setHoursWorked(double hours)
{
    hoursWorked = hours;
}

double FireEmployee::getHoursWorked()
{
    return hoursWorked;
}

void FireEmployee::print() const
{
    cout << "Id: " << getId() << endl;
    cout << "Name: ";
    personType::print();
    cout << endl;
    cout << "Wages: $" << calculatePay() << endl;
}
double FireEmployee::calculatePay() const
{
    return (FirepayRate * hoursWorked);
}
///constructor
FireEmployee::FireEmployee(string first, string last,
                                   long id,
                                   double rate, double hours)
                 :employeeType(first, last, id)
{
    FirepayRate = rate;
    hoursWorked = hours;
}

///============================================================================
//The following function main tests these classes

#include <iostream>
//#include "FireEmployee.h"
//#include "HireEmployee.h"
int main()
{
HireEmployee newEmp("John", "Smith", 75, 56000, 5700);
FireEmployee firepEmp("Bill", "Nielson", 275, 15.50, 57);
newEmp.print();
cout << endl;
firepEmp.print();

return 0;
}
Line 12: personType is defined nowhere in your program
The colon should be before public.

 
class employeeType : public personType
Topic archived. No new replies allowed.