G
gob00st
FAQ [13.9]
<Quote>
9.If you define x++ and ++x, maintain the usual identities. For
example, x++ and ++x should have should have the same observable
effect on x, and should differ only in what they return. ++x should
return x by reference; x++ should either return a copy (by value) of
the original state of x or should have a void return-type. You're
usually better off returning a copy of the original state of x by
value, especially if your class will be used in generic algorithms.
</Quote>
I understand this suggesting we should try to keep user defined post/
pre incremental operator to mimic the behaviour of intrinsic type, but
any idea
why pre-incremental returns reference and post-incremental returns a
copy .
Regards,
Gob00st
<Quote>
9.If you define x++ and ++x, maintain the usual identities. For
example, x++ and ++x should have should have the same observable
effect on x, and should differ only in what they return. ++x should
return x by reference; x++ should either return a copy (by value) of
the original state of x or should have a void return-type. You're
usually better off returning a copy of the original state of x by
value, especially if your class will be used in generic algorithms.
</Quote>
I understand this suggesting we should try to keep user defined post/
pre incremental operator to mimic the behaviour of intrinsic type, but
any idea
why pre-incremental returns reference and post-incremental returns a
copy .
Regards,
Gob00st