-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultilevelInheritance.cpp
68 lines (56 loc) · 952 Bytes
/
multilevelInheritance.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_no;
public:
void get_number(int a);
void put_number();
};
void student::get_number(int a)
{
roll_no = a;
}
void student::put_number()
{
cout << "Roll number : " << roll_no << "\n";
}
class test : public student
{
protected:
float sub1, sub2;
public:
void get_marks(float x, float y);
void put_marks();
};
void test::get_marks(float x, float y)
{
sub1 = x;
sub2 = y;
}
void test::put_marks()
{
cout << "Marks of sub1 : " << sub1 << "\n";
cout << "Marks of sub2 : " << sub2 << "\n";
}
class result : public test
{
float total;
public:
void display()
{
total = sub1 + sub2;
put_number();
put_marks();
cout << "Total : " << total;
}
};
int main()
{
result student1;
student1.get_number(100);
student1.get_marks(89, 94);
student1.display();
return 0;
}