Difficulty: Easy
Correct Answer: 200
Explanation:
Introduction / Context:
This asks about composition (a member object inside another class) and confirms that this->y
is simply the member y
of the same CuriousTabBase
instance, not anything special about inheritance.
Given Data / Assumptions:
objBase
is constructed with xx=10
, yy=20
.Show()
prints x * this->y
.iostream.h
header; ignore modern header conventions.
Concept / Approach:
After member initialization, x=10
and y=20
. The product x * this->y
equals 10 * 20
.
Step-by-Step Solution:
1) Member initialization list sets the contained object's fields.2) Call to objBase.Show()
prints 10 * 20 = 200
.3) No hidden conversions or pointer tricks are involved.
Verification / Alternative check:
Output x
and y
separately to confirm they are 10 and 20 before multiplication.
Why Other Options Are Wrong:
0 and 100/400 imply incorrect values; there is no compile error because all members are accessible and properly initialized.
Common Pitfalls:
Confusing composition with inheritance or misreading this->y
as something other than the member y
.
Final Answer:
200
Discussion & Comments