forked from mrizky-kur/Redux-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hybrid_Inheritance.cpp
98 lines (94 loc) · 1.7 KB
/
Hybrid_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
90
91
92
93
94
95
96
97
98
#include<iostream>
using namespace std;
class Number
{
protected:
int no;
public:
Number()
{
no=0;
}
~Number(){}
void setData()
{
cout<<"\nEnter Number:";
cin>>no;
}
void display()
{
cout<<"\nEnter Number:"<<no;
}
};
class Name:public Number
{
protected:
char nm[15];
public:
Name():Number()
{
nm[0]='\0';
}
~Name(){}
void setData()
{
Number::setData();
cout<<"\nName:";
cin>>nm;
}
void display()
{
Number::display();
cout<<"\nName:"<<nm;
}
};
class Sports
{
protected:
int smrk;
public:
Sports()
{
smrk=0;
}
~Sports(){}
void setData()
{
cout<<"\nSports Marks:";
cin>>smrk;
}
void display()
{
cout<<"\nSports Marks:"<<smrk;
}
};
class Result:public Name,public Sports
{
protected:
int tmrk;
public:
Result():Name(),Sports()
{
tmrk=0;
}
~Result(){}
void setData()
{
Name::setData();
Sports::setData();
cout<<"\nTheory Marks:";
cin>>tmrk;
}
void display()
{
Name::display();
Sports::display();
cout<<"\nTheory:"<<tmrk;
}
};
int main()
{
Result r;
r.setData();
r.display();
}