forked from jainaman224/Algo_Ds_Notes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hierarchical.cpp
101 lines (81 loc) · 1.43 KB
/
Hierarchical.cpp
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
#include <iostream>
using namespace std;
class person
{
private:
string name;
long int phno;
public:
void read()
{
name = "Akash";
phno = 9283749093;
}
void show()
{
cout << "\nName = " << name;
cout << "\nPhone = " << phno;
}
};
class student : public person
{
private:
int rollno;
string course;
public:
void read()
{
person::read();
rollno = 007;
course = "Computer Science";
}
void show()
{
person::show();
cout << "\nRoll No. = " << rollno;
cout << "\nCourse = " << course;
}
};
class teacher : public person
{
private:
string dept_name;
string qual;
public:
void read()
{
person::read();
dept_name = "CSE";
qual = "PhD";
}
void show()
{
person::show();
cout << "\nDepartement = " << dept_name;
cout << "\nQualififcation = " << qual;
}
};
int main()
{
student s1;
s1.read();
cout << "\n************************ Displaying Student Information*************";
s1.show();
teacher t1;
t1.read();
cout << "\n*****************************Displaying Teacher Information************";
t1.show();
return 0;
}
/* OUTPUT
************************ Displaying Student Information*************
Name = Akash
Phone = 9283749093
Roll No. = 007
Course = Computer Science
*****************************Displaying Teacher Information************
Name = Akash
Phone = 9283749093
Department = CSE
Qualification = PhD
*/