forked from PrafullRaj/Hacktober2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiple_Inheritance.cpp
More file actions
48 lines (42 loc) · 1.16 KB
/
Multiple_Inheritance.cpp
File metadata and controls
48 lines (42 loc) · 1.16 KB
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
#include <iostream>
using namespace std;
// create a base class1
class Base_class
{
// access specifier
public:
// It is a member function
void display()
{
cout << " It is the first function of the Base class " << endl;
}
};
// create a base class2
class Base_class2
{
// access specifier
public:
// It is a member function
void display2()
{
cout << " It is the second function of the Base class " << endl;
}
};
/* create a child_class to inherit features of Base_class and Base_class2 with access specifier. */
class child_class: public Base_class, public Base_class2
{
// access specifier
public:
void display3() // It is a member function of derive class
{
cout << " It is the function of the derived class " << endl;
}
};
int main ()
{
// create an object for derived class
child_class ch;
ch.display(); // call member function of Base_class1
ch.display2(); // call member function of Base_class2
ch.display3(); // call member function of child_class
}