S
subramanian100in
For a class Test, we write the assignment operator as
Test & Test:perator=(const Test & rhs);
instead of
const Test & Test:perator=(const Test & rhs);
that is, the return type of operator=( ) is just a reference, not a
reference to const object.
is it because to allow for expressions such as
(x = y) + z;
where x, y, z are of type Test ?
What would happen if we allowed "const Test &" as the return type of
Test:perator=( ) ?
Kindly clarify.
Thanks
V.Subramanian
Test & Test:perator=(const Test & rhs);
instead of
const Test & Test:perator=(const Test & rhs);
that is, the return type of operator=( ) is just a reference, not a
reference to const object.
is it because to allow for expressions such as
(x = y) + z;
where x, y, z are of type Test ?
What would happen if we allowed "const Test &" as the return type of
Test:perator=( ) ?
Kindly clarify.
Thanks
V.Subramanian