-
Notifications
You must be signed in to change notification settings - Fork 0
/
multiple_inheritance.cpp
77 lines (76 loc) · 1.19 KB
/
multiple_inheritance.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
#include<iostream>
using namespace std;
class student{
protected:
char na[20];
int r,c,m;
public:
void getname()
{
cout<<"enter name";
cin>>na;
}
void getroll()
{
cout<<"enter roll no.";
cin>>r;
}
void getclass()
{
cout<<"enter class";
cin>>c;
}
void getmark()
{
cout<<"enter total marks for all subjects";
cin>>m;
}
void display()
{
cout<<"name is"<<na<<endl;
cout<<"roll no. is"<<r<<endl;
cout<<"class is"<<c<<endl;
cout<<"marks for all subjects is"<<m<<endl;
}
};
class sports{
protected:
int n;
public:
void getevent()
{
cout<<"enter no. of sports events";
cin>>n;
}
void disevent()
{
cout<<"no. of sports events participated is"<<n<<endl;
}
};
class mark:public student,public sports{
public:
int p;
int total(){
cout<<"mark for each sports item is 10";
p=n*10;
cout<<"total marks for sports is"<<p<<endl;
return(p+m);}
};
int main()
{
int s,i;
mark ma[10];
cout<<"enter no. of students";
cin>>s;
for(i=0;i<s;i++)
{
ma[i].getname();
ma[i].getroll();
ma[i].getclass();
ma[i].getmark();
ma[i].getevent();
ma[i].display();
ma[i].disevent();
cout<<"total mark is"<<ma[i].total()<<endl;
}
}