Chapter 14: Problem 14
Why shouldn't a class's overloaded = operator be implemented with a void operator function?
Short Answer
Expert verified
Answer: Implementing an overloaded assignment operator as a void function in a class would not allow for proper functionality when trying to perform multiple assignments in one statement. This is because the return value of each assignment is necessary for the next assignment to work. The correct implementation should return a reference to the current object, ensuring that the chain of multiple assignments works as expected and adhering to the principle of least astonishment.