c++ post and pre increment operators - slightly off topic

Gianni Mariani marianig@orconet.com
Thu Jul 27 11:12:00 GMT 2000


Excellent idea - tried it - no luck - article -
97DF3CB.F0B9F9AB%40orconet.com .

I thought that the semanic was that the operator was a
"side effect", hence the method should be called after the
expression was evaluated.  My bad.  Hence I thought
it was a compiler boog.

my *bad* assumption was that :

    y = z ++ + z ++ should be the same as (y = z + z), z++, z++

I could not find any reference to the contrary.  I did RTFM.

Lei Ming wrote:

> Hi,
>
> You post your question to wrong place. You should go to c++ news group.
>
> Post increment did go before reference. The problem is your
> implementation.
> In "foo operator ++(int num)", you should return the old value not the new
>
> value. That is the semantic meaning of post increment.
>
> Lei



More information about the Gcc-help mailing list