-
Notifications
You must be signed in to change notification settings - Fork 170
/
multilevel inheritance
63 lines (63 loc) · 1.1 KB
/
multilevel inheritance
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
#include<iostream>
using namespace std;
class worker
{
protected:
int age;
char name[20];
public:
void get()
{
cout<<"enter the name:";
cin>>name;
cout<<"enter the age:";
cin>>age;
}
void show()
{
cout<<"***************************************************************";
cout<<endl<<"name:"<<name<<endl;
cout<<"age:"<<age<<endl;
}
};
class manager:public worker
{
protected:
int number_of_workers;
public:
void get1()
{
cout<<"enter the number of workers:";
cin>>number_of_workers;
}
void show1()
{
cout<<"number of workers:"<<number_of_workers<<endl;
}
};
class ceo: public manager
{
protected:
int no_of_managers;
public:
void get2()
{
cout<<"enter the number of managers:";
cin>>no_of_managers;
}
void show2()
{
cout<<"number of managers:"<<no_of_managers<<endl;
}
};
int main()
{
ceo obj;
obj.get();
obj.get1();
obj.get2();
obj.show();
obj.show1();
obj.show2();
return 0;
}