+ 1
C++ beginner question
Why does int a = 3; int b = 2; b = a++; cout << b; Print as just the number 3? I saw it as b changing to the value of a then adding 1, apparently this isn’t the case. What’s actually happening?
3 Respuestas
+ 2
++ after the name means the value increases after the operation.
So b gets a's old value 3, then a becomes 4.
- 1
++b
- 2
Don't do that, do b=++a