You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Checked, the result is x=1, y=0
My bad, wrong result description!
My bad, wrong description of the results!
Key :
https://www.mql5.com/ru/docs/basis/operations/rules
The c++ standard does not define this place and explicitly says that it depends on the implementation. There are 2 main implementations:
1. Produce a postincrement immediately after the variable is used in the expression. (as we have done).
2. Postincrement after the whole expression is calculated.
Key :
https://www.mql5.com/ru/docs/basis/operations/rules
x=0; y=0; x = y++; // x = 1 !!!
x=0; y=0; y = y++; // y = 0 !!!
Did the priority of the operations manage to change ?
x=0; y=0; x = y++; // x = 1 !
Completely confused!
x=0; y=0; x = y++; // x = 0 ? y= 1 !!!
x=0; y=0; y = y++; // y = 0 !!!
x=0; y=0; x = y++; // x = 0 ? y= 1 !!!
Perfectly correct in all postincrement implementations without exception.
If you walk the behaviour you seem to be expecting, use preincrement. x = ++y;
Completely confused!
x=0; y=0; x = y++; // x = 0 ? y= 1 !!!
x=0; y=0; y = y++; // y = 0 !!!
Section Arithmetic operations:
Increment and decrement operations apply only to variables, they do not apply to constants. Prefix increment (++i) and decrement (--k) are applied to a variable just before that variable is used in an expression.
Postfix increments (i++) and decrements (k--) are applied to a variable immediately after that variable is used in an expression.
Section Arithmetic operations:
...Postfix increments (i++) and decrements (k--) are applied to a variable immediately after that variable is used in an expression.
Both lines have postfix increment. The result (y) is different. It turns out that it depends on the context of application...