C++ Programming Tips: Return of ‘operator=’ and Self-Assignment Handling
1. ‘operator=’ Must Return a Reference to ‘*this’ The assignment operator has a commonly used form, chained assignment: Chained assignment uses right associativity, as mentioned in the comments. The issue arises that for chained assignment to work, the return value inside the parentheses must be of type ‘int’. Similarly, for our user-defined functions to use … Read more