2

Possible Duplicate:
Overloading assignment operator in C++
C++ why the assignment operator should return a const ref in order to avoid (a=b)=c

Why do most books recommend that the assignment operator return a refernce to this? Why not a const reference?

const will make strange code like (a=b)=c not compile which is a good thing.

Community
  • 1
  • 1
OopsUser
  • 4,642
  • 7
  • 46
  • 71
  • 1
    ...and this: http://stackoverflow.com/questions/2649068/has-anyone-found-the-need-to-declare-the-return-parameter-of-a-copy-assignment-o – Jason S May 07 '12 at 13:17

0 Answers0