x = 1;
std::cout << ((++x)+(++x)+(++x));
I expect the output to be 11
, but it's actually 12
. Why?
We explain it by expecting undefined behaviour rather than any particular result. As the expression attempts to modify x multiple times without an intervening sequence point its behaviour is undefined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With