+ 2
Can You Explain?
int a = 3 int b = 2 b = a++ cout << ++b outputs 4. so i understand it but i dont REALLY understand it. they say a++ changes changes the value of b to a but doesnt increment till the cout line is ran but ++b increments then changes the value. i dont get it đ . any help would be fantastic THANKS!!
5 Answers
+ 21
b gets the value of a (3) and then a is incremented afterwards b is incremented once before output (4)
(~_~)
+ 8
b=a++ means b=a and a=a+1
cout<<++b means b=b+1 and cout<<b
+ 3
when u do ++a means the value increments and sets the incremented value to b.
b = ++a;// a=a+1; b=a;
when you do a++ means the initial value will be stored in b ,the value will be incremented.
b = a++;//b=a; a=a+1;
+ 1
yea i know but why does a++ basically just make b inherit the value of a and nothing more? why not just say b = 3?
+ 1
like why does b=a++ not make b 4? it takes 3 1ST then what, it just completly forgets about the ++ part and doesnt increment it? thats what doesnt make sense.