What does a conventional copy assignment operator for class X return?
Correct answer A. A reference to *this, of type X&
Returning X& (that is, *this) lets assignments chain, as in a = b = c, and matches the behaviour of built-in types. Returning void would break chaining, while returning by value would create unnecessary copies. The compiler-generated copy and move assignment operators also return X&, so user-defined versions should follow the same convention.
Answer checked How we write and check questions
Discussion