forked from jainaman224/Algo_Ds_Notes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Multiple.cpp
65 lines (51 loc) · 964 Bytes
/
Multiple.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
#include <iostream>
using namespace std;
class lectures
{
protected:
int rollno, marks1, marks2;
public:
void get()
{
rollno = 007;
marks1 = 75;
marks2 = 50;
}
};
class sports
{
protected:
int sportsmarks;
public:
void getsportsmarks()
{
sportsmarks = 100;
}
};
class result : public lectures, public sports // Result class inherited from lectures and sports
{
private:
int total, average;
public:
void display()
{
total = (marks1+marks2+sportsmarks);
average = total/3.0;
cout << "\nRoll No : " << rollno;
cout << "\nTotal: " << total;
cout << "\nAverage : " << average;
}
};
int main()
{
result obj;
obj.get();
obj.getsportsmarks();
obj.display();
return 0;
}
/* OUTPUT
Roll No: 007
Total: 225
Average: 75
*/