forked from thakursaurabh1998/cpp
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhybridInheritance.cpp
68 lines (62 loc) · 891 Bytes
/
hybridInheritance.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
#include<iostream>
using namespace std;
class Student
{
protected:
int roll;
public:
void get_roll(int x){roll=x;}
void put_roll()
{
cout << "Roll No: " << roll << endl;
}
};
class Test : public Student
{
protected:
float sub1, sub2;
public:
void get_marks(float x, float y)
{
sub1=x;
sub2=y;
}
void put_marks()
{
cout << "Sub1: " << sub1 << endl;
cout << "Sub2: " << sub2 << endl;
}
};
class Sports
{
protected:
float score;
public:
void get_score(float x){score=x;}
void put_score()
{
cout << "Score: " << score << endl;
}
};
class Result : public Test, public Sports
{
float total;
public:
void display()
{
total = sub1+sub2+score;
put_roll();
put_marks();
put_score();
cout << "Total: " << total << endl;
}
};
int main()
{
Result std1;
std1.get_roll(1001);
std1.get_marks(40.4,60.6);
std1.get_score(7.7);
std1.display();
return 0;
}