+ 5
Chanllenge problem
When I have a chanllenge in C++,a problem that I can't catch is that: int x=2; cout<<(x- ++ --x); why the output is 0? what is meaning of "-";
13 Respostas
+ 7
If x ++ will be collected
Int x = 5;
Int y = 10;
cout << ++ x + y;
_________________________________
Int x = 5;
Int y = 10;
cout << x ++ + y;
If ++ x will ignore the variable because it is after x
But its x ++ values will remain unchanged
But will display if you eject x again
Will collect 1 + x and thus the result will become {6}
In the other direction I did
count << x;
_________________________________
I hope you understand my words and if you want to understand the more I have in the conversation
+ 3
Ok,I get it,maybe I have never seen this usage before,haha.Thanks
+ 3
Due to operator precedence. Answer will be zero
+ 2
But there is operater precedence.
+ 2
👍🤗
+ 2
👍
+ 1
I think it's equal to :
x - (++ (--x)) ;
So it's the same than x - x
+ 1
But I think that operator is not vaild because between '-' and '++',there is no brackets,this is so confused
+ 1
So are there compilers where the output can be different? Or code is always translated in the same way?
+ 1
Thanks!