-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path8_4.cpp
88 lines (84 loc) · 1.64 KB
/
8_4.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
#include "bits./stdc++.h"
using namespace std;
class hospital
{
string name;
int roll_no;
public:
void get_data()
{
// cout << "enter name : ";
cin >> name;
// cout << "enter roll no : ";
cin >> roll_no;
}
void print_data()
{
cout << "name = " << name << endl
<< "roll_no = " << roll_no << endl;
}
};
class ward : virtual public hospital
{
int ward_no;
public:
void get_data()
{
// cout << "enter ward number : ";
cin >> ward_no;
}
void print_data()
{
cout << "ward_no = " << ward_no << endl;
}
};
class room : virtual public hospital
{
int bed_number;
string nature_of_illness;
public:
void get_data()
{
// cout << "enter bed number : ";
cin >> bed_number;
// cout << "enter nature of illness : ";
cin >> nature_of_illness;
}
void print_data()
{
cout << "bed number = " << bed_number << endl
<< "nature of illness = " << nature_of_illness;
}
};
class patient : public ward, public room
{
public:
void get_data()
{
hospital::get_data();
ward::get_data();
room::get_data();
}
void print_data()
{
hospital::print_data();
ward::print_data();
room::print_data();
}
};
int main()
{
int n = 5;
patient p[5];
for (int i = 0; i < n; i++)
{
cout << "enter for " << i + 1 << "patient" << endl;
p[i].get_data();
}
for (int i = 0; i < n; i++)
{
cout << "value for " << i + 1 << "patient" << endl;
p[i].print_data();
}
return 0;
}