-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path51.cpp
More file actions
51 lines (44 loc) · 745 Bytes
/
Copy path51.cpp
File metadata and controls
51 lines (44 loc) · 745 Bytes
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
//WAP in C++ for showing working of virtual base class.
#include<iostream>
using namespace std;
class GrandParent
{
public:
void display()
{
cout<< "Grand Parent Class!\n";
}
};
class Parent1: virtual public GrandParent
{
public:
void display1()
{
cout<< "Parent1 Class!\n";
}
};
class Parent2: virtual public GrandParent
{
public:
void display2()
{
cout<< "Parent2 Class!\n";
}
};
class Child: public Parent1, public Parent2
{
public:
void display3()
{
cout<< "Child Class!\n";
}
};
int main()
{
Child obj;
obj.display();
obj.display1();
obj.display2();
obj.display3();
return 0;
}