Here's my code:
int main() {
static int test = 0;
const int anotherInt = 1;
test = anotherInt > test ? test++ : 0;
if (anotherInt > test)
test++;
else
test = 0;
return 0;
}
Here's the warning produced when I build it:
../main.cpp:15:40: warning: operation on ‘test’ may be undefined [-Wsequence-point]
test= anotherInt>test ? test++ : 0;
^
Why does C++ give me a warning on the ternary operation, but not the regular if..else
statement?