1 | struct A { |
2 | explicit A(int u) { _u._u3 = u; } |
3 | A(const A &) = default; |
4 | virtual ~A() = default; |
5 | |
6 | private: |
7 | union U { |
8 | char _u1; |
9 | short _u2; |
10 | int _u3; |
11 | }; |
12 | |
13 | A::U _u; |
14 | }; |
15 | |
16 | #pragma pack(push, 1) |
17 | template <int I> struct B : public virtual A { |
18 | B(char a, unsigned short b, int c) : A(a + b + c), _a(a), _b(b), _c(c) {} |
19 | |
20 | private: |
21 | char _a; |
22 | unsigned short : 3; |
23 | unsigned short _b : 6; |
24 | unsigned short : 4; |
25 | int _c; |
26 | }; |
27 | #pragma pack(pop) |
28 | |
29 | #pragma pack(push, 16) |
30 | class C : private virtual B<0>, public virtual B<1>, private B<2>, public B<3> { |
31 | public: |
32 | C(char x, char y, char z) |
33 | : A(x - y + z), B<0>(x, y, z), B<1>(x * 2, y * 2, z * 2), |
34 | B<2>(x * 3, y * 3, z * 3), B<3>(x * 4, y * 4, z * 4), _x(x * 5), |
35 | _y(y * 5), _z(z * 5) {} |
36 | |
37 | static int abc; |
38 | |
39 | private: |
40 | int _x; |
41 | short _y; |
42 | char _z; |
43 | }; |
44 | int C::abc = 123; |
45 | #pragma pack(pop) |
46 | |
47 | class List { |
48 | public: |
49 | List() = default; |
50 | List(List *p, List *n, C v) : Prev(p), Next(n), Value(v) {} |
51 | |
52 | private: |
53 | List *Prev = nullptr; |
54 | List *Next = nullptr; |
55 | C Value{1, 2, 3}; |
56 | }; |
57 | |
58 | int main() { |
59 | List ls[16]; |
60 | return 0; |
61 | } |
62 | |