1 | class MyClass |
---|---|
2 | { |
3 | public: |
4 | int memberResult() |
5 | { |
6 | return 1; |
7 | } |
8 | static int staticResult() |
9 | { |
10 | return 1; |
11 | } |
12 | int externResult(); |
13 | }; |
14 | |
15 | // -- |
16 | |
17 | int MyClass::externResult() |
18 | { |
19 | return 1; |
20 | } |
21 | |
22 | // -- |
23 | |
24 | MyClass m; |
25 | |
26 | // -- |
27 | |
28 | enum MyEnum { |
29 | myEnumOne = 1, |
30 | myEnumTwo, |
31 | myEnumThree |
32 | }; |
33 | |
34 | // -- |
35 | |
36 | class AnotherClass |
37 | { |
38 | public: |
39 | __attribute__ ((always_inline)) int complicatedFunction() |
40 | { |
41 | struct { |
42 | int i; |
43 | } s = { .i: 15 }; |
44 | |
45 | int numbers[4] = { 2, 3, 4, 5 }; |
46 | |
47 | for (signed char number: numbers) |
48 | { |
49 | s.i -= number; |
50 | } |
51 | |
52 | return s.i; |
53 | } |
54 | }; |
55 | |
56 | // -- |
57 | |
58 | class DiamondA |
59 | { |
60 | private: |
61 | struct { |
62 | int m_i; |
63 | }; |
64 | public: |
65 | DiamondA(int i) : m_i(i) { } |
66 | int accessor() { return m_i; } |
67 | }; |
68 | |
69 | // -- |
70 | |
71 | class DiamondB : public virtual DiamondA |
72 | { |
73 | public: |
74 | DiamondB(int i) : DiamondA(i) { } |
75 | }; |
76 | |
77 | // -- |
78 | |
79 | class DiamondC : public virtual DiamondA |
80 | { |
81 | public: |
82 | DiamondC(int i) : DiamondA(i) { } |
83 | }; |
84 | |
85 | // -- |
86 | |
87 | class DiamondD : public DiamondB, public DiamondC |
88 | { |
89 | public: |
90 | DiamondD(int i) : DiamondA(i), DiamondB(i), DiamondC(i) { } |
91 | }; |
92 | |
93 | // -- |
94 | |
95 | int doTest() |
96 | { |
97 | int accumulator = m.memberResult(); |
98 | accumulator += MyClass::staticResult(); |
99 | accumulator += m.externResult(); |
100 | accumulator += MyEnum::myEnumThree; |
101 | accumulator += myEnumOne; |
102 | accumulator += AnotherClass().complicatedFunction(); |
103 | accumulator += DiamondD(3).accessor(); |
104 | return accumulator; |
105 | } |
106 | |
107 | // -- |
108 |