+ 1
what is prefix and postfix?
whats their diffrence?
3 Réponses
+ 3
postfix
y=x++
means y=x and then x=x+1
prefix
y=++x
means x=x+1 and then y=x
0
زیزدی
0
@Vipin
Everything is right, but you can put it alone:
int x=1;
x++;
// x has value 2
x=3;
++x;
// x has value 4
it is suggested to use more often prefix, because:
int y=5;
cout << ++y; //output 6
but:
int z=5;
cout << z++; //output 5
To clarify - in post incrementation compiler first uses the original value, and then increments, not like in pre incrementation.