1 #include <stdio.h>
2 #include <stdint.h>
3
4 class A
5 {
6 public:
A(int a)7 A(int a) :
8 m_a(a)
9 {
10 }
~A()11 virtual ~A(){}
get2() const12 virtual int get2() const { return m_a; }
get() const13 virtual int get() const { return m_a; }
14 protected:
15 int m_a;
16 };
17
18 class B : public A
19 {
20 public:
B(int a,int b)21 B(int a, int b) :
22 A(a),
23 m_b(b)
24 {
25 }
26
~B()27 ~B() override
28 {
29 }
30
get2() const31 int get2() const override
32 {
33 return m_b;
34 }
get() const35 int get() const override
36 {
37 return m_b;
38 }
39
40 protected:
41 int m_b;
42 };
43
44 struct C
45 {
CC46 C(int c) : m_c(c){}
~CC47 virtual ~C(){}
48 int m_c;
49 };
50
51 class D : public C, public B
52 {
53 public:
D(int a,int b,int c,int d)54 D(int a, int b, int c, int d) :
55 C(c),
56 B(a, b),
57 m_d(d)
58 {
59 }
60 protected:
61 int m_d;
62 };
main(int argc,char const * argv[],char const * envp[])63 int main (int argc, char const *argv[], char const *envp[])
64 {
65 D *good_d = new D(1, 2, 3, 4);
66 D *d = nullptr;
67 return d->get();
68 }
69
70