thanks for the advice, and spaceship

Jeffrey Traer Bernstein jeffyb@ccrma.Stanford.EDU
Tue, 13 May 2003 22:54:18 -0700


As dave concurred your second example is faster.
However both loops will output 012
These operators as pre & post-ASSIGNMENT-incrments so if there is no 
assignment i.e. an explicit = then they're result is exaclty the same.

Hiroko Terasawa wrote:

>is there difference in the performance?
>(pre-assignment and post-assignment)
>
>for(i=0 ; i<3 ; i++){
>array[i] = 0; // array[0] = array[1] = array[2] = 0.
>cout << i;  // it will show 012
>}
>
>for(i=0 ; i<3 ; ++i){
>array[i] = 0; // array[1] = array[2] = array[3] = 0 ?
>cout << i; // does it show 123?
>}
>
>did you like the spaceship?? 
>
>  
>