-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHybrid_Inheritance.cpp
More file actions
76 lines (58 loc) · 1.03 KB
/
Copy pathHybrid_Inheritance.cpp
File metadata and controls
76 lines (58 loc) · 1.03 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
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
class student
{
private:
int id;
char name[20];
public:
void getstudent()
{
cout<<"Enter student name : ";cin>>name;
cout<<"\nEnter student ID : ";cin>>id;
}
};
class marks : public student
{
protected:
int m1 , m2 , m3;
public:
void getmarks()
{
cout<<"\nEnter marks of the three subjects : ";cin>>m1>>m2>>m3;
}
};
class sports
{
protected:
int smark;
public:
void getsportsmarks()
{
cout<<"\nEnter marks obtained in sports : ";cin>>smark;
}
};
class result : public marks , public sports
{
private:
int total;
float average;
public:
void showresult()
{
total = (m1 + m2 + m3 + smark);
average = (total / 4.0);
cout<<"\nTotal marks obtained = "<<total;
cout<<"\nAverage marks obtained = "<<average<<endl;
}
};
int main()
{
result r;
r.getstudent();
r.getmarks();
r.getsportsmarks();
r.showresult();
return 0;
}