-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathInheritance.cpp
More file actions
230 lines (199 loc) · 3.55 KB
/
Inheritance.cpp
File metadata and controls
230 lines (199 loc) · 3.55 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#include<iostream>
#include<string.h>
using namespace std;
class base1
{
protected:
char name[30];
char dob[10];
char bloodgrp[3];
public:
char id[10];
};
class base2
{
protected:
float height;
float weight;
};
class base3
{
protected:
char policyno[30];
char contactaddr[50];
};
class derived:public base1,public base2,public base3
{
protected:
char phnno[20];
char licenceno[10];
public:
static int count;
void read();
void print();
void insert();
int search(char t[10]);
int delete_(char j[10]);
};
int derived::count;
void derived::read()
{
cout<<"enter the id:"<<endl;
cin>>id;
cout<<"enter the name:"<<endl;
cin>>name;
cout<<"enter the dob:"<<endl;
cin>>dob;
cout<<"enter the bloodgrp:"<<endl;
cin>>bloodgrp;
cout<<"enter the height:"<<endl;
cin>>height;
cout<<"enter the weight:"<<endl;
cin>>weight;
cout<<"enter the policyno:"<<endl;
cin>>policyno;
cout<<"enter the contactaddr:"<<endl;
cin>>contactaddr;
cout<<"enter the phnno:"<<endl;
cin>>phnno;
cout<<"enter the licenceno:"<<endl;
cin>>licenceno;
}
void derived::print()
{
cout<<"id is:"<<id<<endl;
cout<<"name is:"<<name<<endl;
cout<<"date of birth is:"<<dob<<endl;
cout<<"blood group is:"<<bloodgrp<<endl;
cout<<"height is:"<<height<<endl;
cout<<"weight is:"<<weight<<endl;
cout<<"policy no. is:"<<policyno<<endl;
cout<<"contact address is:"<<contactaddr<<endl;
cout<<"concat no. is"<<phnno<<endl;
cout<<"licence no. is:"<<licenceno<<endl;
}
void derived::insert()
{
cout<<"enter the id:"<<endl;
cin>>id;
cout<<"enter the name:"<<endl;
cin>>name;
cout<<"enter the dob:"<<endl;
cin>>dob;
cout<<"enter the bloodgrp:"<<endl;
cin>>bloodgrp;
cout<<"enter the height:"<<endl;
cin>>height;
cout<<"enter the weight:"<<endl;
cin>>weight;
cout<<"enter the policyno:"<<endl;
cin>>policyno;
cout<<"enter the contactaddr:"<<endl;
cin>>contactaddr;
cout<<"enter the phnno:"<<endl;
cin>>phnno;
cout<<"enter the licenceno:"<<endl;
cin>>licenceno;
}
int derived::search(char t[10])
{
int flag=1;
flag=strcmp(id,t);
if(flag==0)
{
cout<<"id is:"<<id<<endl;
cout<<"name is:"<<name<<endl;
cout<<"date of birth is:"<<dob<<endl;
cout<<"blood group is:"<<bloodgrp<<endl;
cout<<"height is:"<<height<<endl;
cout<<"weight is:"<<weight<<endl;
cout<<"policy no. is:"<<policyno<<endl;
cout<<"contact address is:"<<contactaddr<<endl;
cout<<"concat no. is"<<phnno<<endl;
cout<<"licence no. is:"<<licenceno<<endl;
return flag;
}
flag=1;
return flag;
}
int derived::delete_(char j[10])
{
int flag=1;
flag=strcmp(id,j);
if(flag==0)
{
//cout<<"---------------";
strcpy(name,"NULL");
strcpy(dob,"NULL");
strcpy(bloodgrp,"NULL");
strcpy(policyno,"NULL");
strcpy(contactaddr,"NULL");
strcpy(phnno,"NULL");
strcpy(contactaddr,"NULL");
height=weight=0;
cout<<"record deleted"<<endl;
return flag;
}
flag=1;
return flag;
}
int main()
{
int i,n=0,ch,j=0;
char x[40],id[10];
derived d1[100];
do
{
cout<<"1)read"<<endl<<"2)display"<<endl<<"3)insert"<<endl<<"4)search"<<endl<<"5)delete"<<endl;
cout<<"6)quit"<<endl;
cout<<"enter ur choice:";
cin>>ch;
switch(ch)
{
case 1: cout<<"\nenter the no. of entries to be inserted:"<<endl;
cin>>n;
for(i=0;i<n;i++)
{
cout<<"\n";
d1[i].read();
}
break;
case 2: cout<<"\nlist of entries"<<endl;
for(i=0;i<n;i++)
{
cout<<"\n";
d1[i].print();
}
break;
case 3: d1[n].insert();
n++;
break;
case 4: cout<<"enter the id to search";
cin>>x;
for(i=0;i<n;i++)
{
j=d1[i].search(x);
}
if(j==1)
{
cout<<"id nt found"<<endl;
}
else
{
cout<<"id found"<<endl;
}
break;
break;
case 5: cout<<"enter the id to delete";
cin>>id;
for(i=0;i<n;i++)
{
j=d1[i].delete_(id);
}
break;
case 6:
break;
}
}while(ch!=6);
return 0;
}