+ 8
Why is ++/-- - different behavior for implementations of type int and my class ? ... there seem to be no errors.
And again post-increment and pre-increment in C ++ ... I thought I already understood ... however, this question and the test code that I wrote says - it's not so simple ... can someone comment on the behavior of this code ( code - https://code.sololearn.com/cu5K39Ppu28M/?ref=app) At the same time, the behavior of the code through my Int class - I think it is correct ... but through the int data type - no.
4 Antworten
+ 6
You must look into sequence point issue.
https://www.sololearn.com/Discuss/2284550/?ref=app
https://www.sololearn.com/Discuss/2111410/?ref=app
+ 9
Avinesh - ok. I understood ... I used to think that this situation is only with post-increment / post-decrement ... now it is clear that the prefix is the same. 🙄
+ 8
Avinesh - thanks.
this is understandable ... but why for the tests (++x - ++x) and (--x - --x) different results are obtained ... moreover, in the case of my class - the result is correct, I think.🤔
+ 5
Michail Getmanskiy you just cannot predict the output. It will result in different values on different compilers.