-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4_2.cpp
More file actions
59 lines (51 loc) · 1.4 KB
/
4_2.cpp
File metadata and controls
59 lines (51 loc) · 1.4 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
#include <iostream>
#include <map>
using namespace std;
class Person {
protected:
string name;
int age;
public:
Person(string n, int a) : name(n), age(a) {}
void displayPerson() {
cout << "Name: " << name << endl;
cout << "Age: " << age << endl;
}
};
class Employee : public Person {
protected:
int employeeID;
public:
Employee(string n, int a, int id) : Person(n, a), employeeID(id) {}
void displayEmployee() {
displayPerson();
cout << "Employee ID: " << employeeID << endl;
}
int getID() {
return employeeID;
}
};
class Manager : public Employee {
string department;
public:
Manager(string n, int a, int id, string dept) : Employee(n, a, id), department(dept) {}
void displayManager() {
displayEmployee();
cout << "Department: " << department << endl << endl;
}
};
int main() {
Manager m1("Pushti", 17, 101, "Engineering");
Manager m2("Reeva", 18, 102, "Marketing");
Manager m3("Khushi", 17, 103, "Finance");
map<int, Manager*> managerMap;
managerMap[m1.getID()] = &m1;
managerMap[m2.getID()] = &m2;
managerMap[m3.getID()] = &m3;
cout << "Displaying all managers from map:\n\n";
for (auto& pair : managerMap) {
pair.second->displayManager();
}
cout<<endl<<"24CE052_pushtikansara"<<endl;
return 0;
}