Saturday, 15 May 2010

c++ - operator= overloading return argument instead of *this -



c++ - operator= overloading return argument instead of *this -

i have theoretical question:

usually, in operator= implementation, returns *this. happens if instead returned *other, other right hand side of assignment?

thanks

reason returning *this enable assignment in form

a = b = c

this same as

a.operator=( b.operator=(c))

if homecoming other, compiler wont able compile kind of assignments.

c++ operator-overloading

No comments:

Post a Comment