Topic: Return value for operator =
Author: b91926@fsgm01.fnal.gov (David Sachs)
Date: 15 Dec 1994 13:51:13 -0600 Raw View
weiss@its.brooklyn.cuny.edu (Gerald Weiss) writes:
>Could anyone explain the rationale behind the default
>operator = having a prototype of
> X &(const X &)
>rather than
> const X &(const X &) ?
>The latter would prevent code such as
> (a = b) = c
>Is there a deliberate intention to allow such code? I have seen
>references to this issue, some in fact offering examples of
>marginal usefullness, but was wondering if there was some application
>of the capability that I was overlooking.
I gues the main rationalle, is to make operator= behave like it does
for non-class object. I can conceive of somebody wanting to write
smething like:
(x=y).a_member = comething; // or
(x=y).non_const_member_function();
Author: weiss@its.brooklyn.cuny.edu (Gerald Weiss)
Date: 14 Dec 1994 17:18:07 -0500 Raw View
Could anyone explain the rationale behind the default
operator = having a prototype of
X &(const X &)
rather than
const X &(const X &) ?
The latter would prevent code such as
(a = b) = c
Is there a deliberate intention to allow such code? I have seen
references to this issue, some in fact offering examples of
marginal usefullness, but was wondering if there was some application
of the capability that I was overlooking.
Thanks,
|
/ \ |\\ |\\ Gerald Weiss
/___\ |// || Department of Computer and Information Science
| | |\\ || Brooklyn College/CUNY
/_____\ |// |//