-
Notifications
You must be signed in to change notification settings - Fork 0
/
Multiple_Inheritance.cpp
89 lines (79 loc) · 1.4 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
78
79
80
81
82
83
84
85
86
87
88
89
// Multiple Inheritance
#include <bits/stdc++.h>
using namespace std;
// Example - 1
// class A
// {
// public:
// int a;
// A()
// {
// cout << "Enter the value of A : ";
// cin >> a;
// }
// };
// class B
// {
// public:
// int b;
// B()
// {
// cout << "Enter the value of B : ";
// cin >> b;
// }
// };
// class C : public A, public B
// {
// public:
// C()
// {
// cout << "The sum of two number : " << a + b << endl;
// }
// };
// Example - 2
class student
{
public:
int roll_no;
string name;
void get_data()
{
cout << "Enter the roll no : ";
cin >> roll_no;
cout << "Enter the name : ";
cin >> name;
}
};
class marks
{
public:
int m1, m2, m3;
void get_marks()
{
cout << "Enter the marks of 3 Subjects\n";
cin >> m1 >> m2 >> m3;
}
};
class result : public marks, public student
{
public:
int total;
void display()
{
total = m1 + m2 + m3;
cout << "\n\nThe Name of student is : " << name << endl;
cout << "The Roll Number of student is : " << roll_no << endl;
cout << "The total marks of " << name << " is " << total << endl;
}
};
int main()
{
// Example - 1
// C obj;
// Example - 2
result lokesh;
lokesh.get_data();
lokesh.get_marks();
lokesh.display();
return 0;
}