0

# C++ Question...

What is the difference of (a = ++b) and (a = b++)?

3 Answers

+ 4

if b is 3, first a will be 4 and b will be 4. second a will be 3 and b will be 4. I think.

+ 4

For b=4
a = ++b will be implemented as
b=b+1; //5
a=b; //5
a= b++ shall be worked out as
a=b; //4
b=b+1; //5

+ 2

a =1 , b=2
a = ++b //a = 3 direct plus one
a= b++ //a = b + 1 , so here b still remain 2