References in C++

Started by
21 comments, last by DigitalDelusion 18 years, 9 months ago
Quote:Original post by _gl_coder_one_
Is this given in Stroustrup ?


No it's a direct quote from the ISO C++ standard from 1998.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
Advertisement
Quote:Original post by DigitalDelusion
The compiler is therefore free to interpret the statement i = i++ as either i = i, ++i or ++i, i = i and which you get is implementation defined.


I should note that the two implementations you've listed will be equivilant, as "i = i" does nothing (as i allready equals i), leaving only ++i in both statements.

AFAIK what you're meaning to say is this:
old_i = i
Then:
i = old_i, ++i;
Or:
++i, i = old_i;
Just clarifying.
Quote:Original post by MaulingMonkey
Quote:Original post by DigitalDelusion
The compiler is therefore free to interpret the statement i = i++ as either i = i, ++i or ++i, i = i and which you get is implementation defined.


I should note that the two implementations you've listed will be equivilant, as "i = i" does nothing (as i allready equals i), leaving only ++i in both statements.

AFAIK what you're meaning to say is this:
old_i = i
Then:
i = old_i, ++i;
Or:
++i, i = old_i;
Just clarifying.


Yes, I was thinking about the order of operations dunno why I swizzled the ++:es around.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats

This topic is closed to new replies.

Advertisement