-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunc_overriding.cpp
More file actions
57 lines (45 loc) · 1016 Bytes
/
func_overriding.cpp
File metadata and controls
57 lines (45 loc) · 1016 Bytes
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
#include <iostream>
using namespace std;
class Employee {
protected:
string name;
int id;
int reportsTo;
public:
Employee(string name, int id, int boss) : name(name), id(id), reportsTo(boss) {}
string getName() {
return name;
}
int getId() {
return id;
}
int getBoss() {
return reportsTo;
}
void display() {
cout << id << " " << name << " reports to " << reportsTo << endl;
}
void display(string salutation) {
cout << salutation << " ";
display();
}
};
class Manager : public Employee {
protected:
string teamName;
public:
Manager(string name, int id, int boss, string teamName) : Employee(name, id, boss), teamName(teamName) {}
void display() {
Employee::display();
cout << " Heads the team " << teamName << endl;
}
};
int main() {
Employee worker("Vidhatha", 10, 2);
Manager ceo("Mehdi", 0, 0, "Sales");
Manager cto("Drit", 2, 0, "Engineering");
worker.display("Mr");
ceo.display();
cto.display();
return 0;
}