Difficulty: Medium
Correct Answer: 11 0 22 0
Explanation:
Introduction / Context:
The problem probes constructor initializer lists for a derived class and a contained member object. It checks whether you can follow which values are passed to the base subobject versus the member subobject and how defaulted parameters are used.
Given Data / Assumptions:
Concept / Approach:
The base subobject of CuriousTabDerived receives only xx, so xx maps to x and the default yy = 0 sets base y to 0. The member object objBase(yy) receives yy as its first argument (xx), while its own second parameter defaults to 0. So objBase.x = yy and objBase.y = 0.
Step-by-Step Solution:
Verification / Alternative check:
If the base initializer were CuriousTabBase(xx, yy) then this->y would be 22; if objBase were constructed as objBase(yy, yy) then objBase.y would be 22. Neither is done here.
Why Other Options Are Wrong:
Common Pitfalls:
Forgetting that default parameters fill omitted ctor args; confusing base-subobject initialization with member-object initialization.
Final Answer:
11 0 22 0
Discussion & Comments