+ 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.

9th Oct 2020, 6:55 PM
Michail Getmanskiy
Michail Getmanskiy - avatar
4 odpowiedzi
9th Oct 2020, 7:03 PM
Avinesh
Avinesh - avatar
+ 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. 🙄
9th Oct 2020, 7:29 PM
Michail Getmanskiy
Michail Getmanskiy - avatar
+ 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.🤔
9th Oct 2020, 7:07 PM
Michail Getmanskiy
Michail Getmanskiy - avatar
+ 5
Michail Getmanskiy you just cannot predict the output. It will result in different values on different compilers.
9th Oct 2020, 7:24 PM
Avinesh
Avinesh - avatar