Skip to main content

Practice ยท 2 of 3

Predict construction order

Implement class Parent with a constructor printing parent and a destructor printing ~parent, and class Child : public Parent whose constructor prints child and destructor prints ~child. Use std::cout exactly (no extra text). The test captures construction/destruction inside a scope.

Difficulty: intermediate

Back to lesson: Practice: Inheritance mechanics