File tree Expand file tree Collapse file tree 2 files changed +63
-1
lines changed Expand file tree Collapse file tree 2 files changed +63
-1
lines changed Original file line number Diff line number Diff line change @@ -24,4 +24,5 @@ set(CMAKE_CXX_STANDARD 20)
24
24
#add_executable(isp_door_better ISP/isp_door_example_better.cpp)
25
25
#add_executable(isp_door_better2 ISP/isp_door_example_better2.cpp)
26
26
#add_executable(isp_device ISP/isp_device_example.cpp)
27
- add_executable (isp_device_better ISP/isp_device_example_better.cpp )
27
+ #add_executable(isp_device_better ISP/isp_device_example_better.cpp)
28
+ add_executable (isp_multiple_inheritance ISP/isp_multiple_inheritance.cpp )
Original file line number Diff line number Diff line change
1
+ //
2
+ // Created by sajith on 4/20/21.
3
+ //
4
+
5
+ #include < iostream>
6
+ #include < memory>
7
+
8
+ class A
9
+ {
10
+ public:
11
+ virtual ~A () = default ;
12
+
13
+ virtual void foo ()
14
+ {
15
+ std::cout << " A\n " ;
16
+ }
17
+ };
18
+
19
+
20
+ class B : public virtual A
21
+ {
22
+ public:
23
+ void foo ()
24
+ {
25
+ std::cout << " B\n " ;
26
+ }
27
+ };
28
+
29
+
30
+ class C : public virtual A
31
+ {
32
+ public:
33
+ void foo ()
34
+ {
35
+ std::cout << " C\n " ;
36
+ }
37
+ };
38
+
39
+
40
+ class D : public B , public C
41
+ {
42
+ public:
43
+ void foo ()
44
+ {
45
+ std::cout << " D\n " ;
46
+ }
47
+ };
48
+
49
+ // Diamond problem
50
+ /*
51
+ /\
52
+ \/
53
+ */
54
+
55
+ int main ()
56
+ {
57
+ std::unique_ptr<A> p = std::make_unique<D>();
58
+ p->foo ();
59
+
60
+ return 0 ;
61
+ }
You can’t perform that action at this time.
0 commit comments