-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserWorkerDriver.cpp
More file actions
79 lines (62 loc) · 1.22 KB
/
UserWorkerDriver.cpp
File metadata and controls
79 lines (62 loc) · 1.22 KB
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
#include <iostream>
#include <string>
#include <locale>
using namespace std;
class User
{
protected:
string name;
int age;
public:
void setName(string n) {
name = n;
}
string getName() {
return name;
}
void setAge(int a) {
age = a;
}
int getAge() {
return age;
}
};
class Worker : public User
{
private:
double salary;
public:
Worker(string n, int a, double s) {
name = n;
age = a;
salary = s;
}
void setSalary(double s) {
salary = s;
}
double getSalary() {
return salary;
}
};
class Driver : public Worker
{
private:
int drivingExperience;
char drivingCategory;
public:
Driver(string n, int a, double s, int exp, char cat)
:Worker(n, a, s)
{
drivingExperience = exp;
drivingCategory = cat;
}
};
int main()
{
setlocale(LC_ALL, "RUS");
Worker ivan("Èâàí", 25, 1000);
Worker vasya("Âàñÿ", 26, 2000);
double averageSalary = (ivan.getSalary() + vasya.getSalary()) / 2.0;
cout << "Ñðåäíÿÿ çàðïëàòà: " << averageSalary << endl;
return 0;
}