vsgdp wrote:
Meyers says to return a reference to *this, but can you also return a copy
of *this? Is the reference for efficiency?
Returning a (non-const) reference allows you to treat the result of
assignment as l-value
Eg : (a=b).foo().
This is not possible if operator=() returns a value.
Also, the "returning by reference" has nothing to do with the actual
behaviour of "assignment" as such. But if you return void from
operator=(), you will not be able to chain assignments
Eg : a = b = c =d ; // needs operator=() return a non-void
Returning by value will add an overhead due to unnecessary calls to
copy constructors.