1 | struct ClassWithImplicitCtor { |
2 | int foo() { return 1; } |
3 | }; |
4 | |
5 | struct ClassWithDefaultedCtor { |
6 | ClassWithDefaultedCtor() = default; |
7 | int foo() { return 2; } |
8 | }; |
9 | |
10 | struct ClassWithOneCtor { |
11 | int value; |
12 | ClassWithOneCtor(int i) { value = i; } |
13 | }; |
14 | |
15 | struct ClassWithMultipleCtor { |
16 | int value; |
17 | ClassWithMultipleCtor(int i) { value = i; } |
18 | ClassWithMultipleCtor(int i, int v) { value = v + i; } |
19 | }; |
20 | |
21 | struct ClassWithDeletedCtor { |
22 | int value; |
23 | ClassWithDeletedCtor() { value = 6; } |
24 | ClassWithDeletedCtor(int i) = delete; |
25 | }; |
26 | |
27 | struct ClassWithDeletedDefaultCtor { |
28 | int value; |
29 | ClassWithDeletedDefaultCtor() = delete; |
30 | ClassWithDeletedDefaultCtor(int i) { value = i; } |
31 | }; |
32 | |
33 | int main() { |
34 | ClassWithImplicitCtor C1; |
35 | C1.foo(); |
36 | ClassWithDefaultedCtor C2; |
37 | C2.foo(); |
38 | ClassWithOneCtor C3(22); |
39 | ClassWithMultipleCtor C4(23); |
40 | ClassWithMultipleCtor C5(24, 25); |
41 | ClassWithDeletedCtor C6; |
42 | ClassWithDeletedDefaultCtor C7(26); |
43 | |
44 | return 0; // break here |
45 | } |
46 | |