0
Can anyone explain me what is postfix and prefix?
Guys, I still haven't understood what postfix and prefix is, can anyone help? For example int x = 1; int y = ++x; //What's this? int x1 = 1; int y1 = x1++; // And this? Thanks
3 Réponses
+ 1
int x = 1;
int y = ++x // increments x then stores it. x = 2, y = 2
x = 1
int z = x++ // stores x then increments. x = 2, z = 1
0
int x = 1;
int y = ++x; // Prefix calcola il valore di x, e poi assegna il suo valore ad y. In questo caso x e y saranno uguali.
int x1 = 1;
int y1 = x1++; // Postfix assegna il valore di x a y, dopo calcola il valore di x. I questo caso y e x saranno diversi, perchè prima y = x, poi x viene modificato aggiungendogli 1.
0
sadly, i dont know.