I am wondering if following expression has defined behavior (always equal to "a=n/(n+1); ++n;
") in C++?
a=n/++n;
I am wondering if following expression has defined behavior (always equal to "a=n/(n+1); ++n;
") in C++?
a=n/++n;
It's undefined. You cannot both modify and access a variable without either having an intervening sequence point or using a single access/modify operator.