-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path28_Multilevel_Inheritance.cpp
More file actions
87 lines (79 loc) · 1.91 KB
/
28_Multilevel_Inheritance.cpp
File metadata and controls
87 lines (79 loc) · 1.91 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
80
81
82
83
84
85
86
87
#include <iostream>
using namespace std;
class EmployeeData
{
char name[30];
int age;
char gender;
public:
void GetBasicInfo(void)
{
cout << "Enter the name : ";
cin >> name;
cout << "Enter the age : ";
cin >> age;
cout << "Enter the gender : ";
cin >> gender;
}
void PrintBasicInfo(void)
{
cout << endl;
cout << "*******************************************"<<endl;
cout << endl;
cout << "Basic Information" << endl;
cout << endl;
cout << "Name : " << name << endl;
cout << "Age : " << age << endl;
cout << "Gender : " << gender << endl;
cout << endl;
}
};
class DepartmentInfo: public EmployeeData
{
char depname[50];
int id;
public:
void GetDepartmentInfo(void)
{
cout << "Enter the Department name : ";
cin >> depname;
cout << "Enter the employee id : ";
cin >> id;
}
void PrintDepartmentInfo(void)
{
cout << endl;
cout << "Department Information"<<endl;
cout << endl;
cout << "Department Name : " << depname << endl;
cout << "Employee id : " << id <<endl;
cout << endl;
cout << "*******************************************"<<endl;
cout << endl;
}
};
class Employee: public DepartmentInfo
{
public:
void GetEmployeeInfo(void)
{
cout << "Enter the employee's Basic information"<<endl;
cout << endl;
EmployeeData::GetBasicInfo();
cout << endl;
cout << "Enter the employee's Department Information" << endl;
cout << endl;
DepartmentInfo::GetDepartmentInfo();
}
void PrintEmployeeInfo(void)
{
EmployeeData::PrintBasicInfo();
DepartmentInfo::PrintDepartmentInfo();
}
};
int main() {
Employee emp;
emp.GetEmployeeInfo();
emp.PrintEmployeeInfo();
}
//try the code at : https://repl.it/@Aravind1444/multilevelinheritancecpp#main.cpp