forked from junaidrahim/Hacktoberfest-KIIT-2021
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HARSHIT VERMA
91 lines (89 loc) · 1.13 KB
/
HARSHIT VERMA
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
#include<iostream>
using namespace std;
class A
{
public:
int a=69;
void printA()
{
cout<<"Class A invoked"<<endl;
}
};
class B:public A
{
public:
int b=25;
void printB()
{
cout<<"Class B invoked"<<endl;
}
};
class G
{
public:
void printG()
{
cout<<"Class G invoked"<<endl;
}
};
class C: public B,public G
{
public:
void printC()
{
cout<<"Class C invoked"<<endl;
}
};
class D: public B
{
public:
void printD()
{
cout<<"Class D invoked"<<endl;
}
};
class E: public C
{
public:
void printE()
{
cout<<"Class E invoked"<<endl;
}
};
class F: public B
{
public:
void printF()
{
cout<<"Class F invoked"<<endl;
}
};
int main()
{
B obj;
cout<<"Single Inheritance"<<endl;
obj.printA();
obj.printB();
cout<<"\n\n Multiple Inheritance"<<endl;
C ob;
ob.printG();
ob.printB();
ob.printC();
cout<<"\n\n Multilevel Inheritance"<<endl;
D d;
d.printA();
d.printB();
d.printD();
cout<<"\n\n Hybrid Inheritance"<<endl;
E e;
e.printA();
e.printB();
e.printC();
e.printE();
cout<<"\n\n Hierarchical Inheritance"<<endl;
F f;
f.printA();
f.printB();
f.printF();
return 1;
}