Difficulty: Medium
Correct Answer: A A A
Explanation:
Introduction / Context:
This example probes constructor selection with default arguments and the order of initialization in inheritance. The derived class calls Base(x) with one argument, forcing selection of the Base overload that has defaults for the remaining parameters, and then chooses which Display to invoke at runtime.
Given Data / Assumptions:
Concept / Approach:
With Base(x) and defaults, y becomes 'A' and z becomes 'B'. The chosen Base constructor sets S = y, A = y + 1 - 1 (thus also 'A'), and M = z - 1 ('B' - 1 → 'A'). Therefore all three printed characters are 'A'.
Step-by-Step Solution:
Verification / Alternative check:
If Derived called Base(x, y) or Base(x, y, z), the printed values could differ. The code as written uses the 1-argument form with defaults.
Why Other Options Are Wrong:
Common Pitfalls:
Worrying about using member x before it is assigned; while x is indeterminate when passed, the selected Base constructor ignores its value for S, A, and M because they depend only on defaulted y and z, leading to deterministic output here.
Final Answer:
A A A
Discussion & Comments