Difficulty: Easy
Correct Answer: The program will print the output 25 25 25 .
Explanation:
Introduction / Context:
This program contrasts direct construction from an int with copy construction from an existing object, and shows that copy initialization uses the copy constructor too. It asks whether all three objects end up with the same observable state.
Given Data / Assumptions:
Concept / Approach:
The user-defined copy constructor assigns x = objB.x (source’s x). Therefore objects constructed from objA will copy 25 into their own x. No undefined behavior occurs and all objects are well-initialized.
Step-by-Step Solution:
Verification / Alternative check:
Modify objA after constructing objB/objC; prints remain the old values because copies are by value, not references.
Why Other Options Are Wrong:
Common Pitfalls:
Believing that copy initialization differs semantically from explicit copy construction in selecting the copy constructor.
Final Answer:
The program will print the output 25 25 25 .
Discussion & Comments