0
Why when i set b to 1, 5 or 10 the answer is always 5 ??? I can't understand it. Please help me
2 Answers
+ 1
b=a++ -> you are using post increment, so first you asing the value of a (5) to b then (next instruction) increments the value of a to 6. Finally you print the value of b (cout << b;) wich is 5. It doesnt matter how you initialize the value of b it always will be overwrite by the value of a.
+ 1
That's because you assign the value of a to be and print it. a++ means that it's value is used in the expression and then incremented.