Difficulty: Easy
Correct Answer: The program will print the output 100 100.
Explanation:
Introduction / Context: This problem checks C++ operator overloading for user-defined types, reference binding to an lvalue object, and calling a member function through a reference after assignment. The code uses an overloaded operator+ that returns a new temporary object whose x and y are element-wise sums.
Given Data / Assumptions:
Concept / Approach: Compute the sum via the overloaded operator, assign the resulting temporary to objRef (alias of objSum), and then display the stored pair. No dynamic memory or undefined behavior is present; the code is well-formed with old iostream headers.
Step-by-Step Solution:
Sum = (90 + 10, 80 + 20) = (100, 100) objRef = Sum; // assigns to objSum via reference objRef.Display() prints "100 100"Verification / Alternative check: If Display were called on objSum directly, it would print the same, proving objRef truly aliases objSum.
Why Other Options Are Wrong:
Common Pitfalls: Confusing reference binding with copying; here objRef and objSum are the same object. Also, operator+ returns a temporary which is then assigned, not a reference to a local.
Final Answer: The program will print the output 100 100.
Discussion & Comments