C/C++ Arena

Step 2 of 8

Order of destruction

Objects are destroyed in the reverse order of construction (last in, first out), and a { } block ends the lifetime of everything declared inside it.

Your turn: without changing the struct, reorder and group the lines in main so the output is exactly:

+ A
+ B
- B
+ C
- C
- A

Previous: Destructors Next: RAII