+ 1
b=a++; cout<<++b;Why ++b still equal to a++?
int a=3; int b=2; b=a++; cout<<++b; Why is ++b's final vauel is 4 not 5?
2 Antworten
+ 2
a=3
b=2
b=a++ -> 1st. b = a; 2nd. a = a+1 -> b = 3; a = 4 (increments after)
cout << ++b -> 1st. b=b+1; 2nd. cout << b (increments before)
0
a++
First returns the value then increments it.
++a
Increments the value before returning it.