Posted by Missy on December 18, 2001 at 18:33:03:
In Reply to: Prefix/Postfix increment operators posted by Andy on December 18, 2001 at 15:21:51:
: How come the Postfix returns Count-1? Got this question from Operators 11; page 93. Thanks for the help.
From my understanding, if you have
y = 5;
y = x++;
The assignment of x to y is done first.
Then x is incremented.
so after:
y = 5;
y = x++;
y would equal 5 and x would equal 6.
For the correct values to be held, count (the value of x) must be incremented, but since it is postfix Count-1 must be return for y to be correct.
Hope that makes sense.