Difficulty: Easy
Correct Answer: The program will print the output 10 20.
Explanation:
Introduction / Context:
This checks basic reference passing into a constructor and immediate printing via a member function. The references are bound to existing lvalues and then copied into data members.
Given Data / Assumptions:
Concept / Approach:
Since the parameters are references, they safely bind to the provided lvalues. Inside the constructor, assignments copy those values into the object. Display then prints the pair.
Step-by-Step Solution:
Verification / Alternative check:
If p or q were changed after construction, the object would not reflect changes because x and y store copies, not references.
Why Other Options Are Wrong:
No compile error or garbage printing occurs; addresses are not printed since the stream inserts ints.
Common Pitfalls:
Confusing reference parameters with reference data members; here only parameters are references.
Final Answer:
The program will print the output 10 20.
Discussion & Comments