<分区>
这是我的代码:
int main() {
static int test = 0;
const int anotherInt = 1;
test = anotherInt > test ? test++ : 0;
if (anotherInt > test)
test++;
else
test = 0;
return 0;
}
这是我构建它时产生的警告:
../main.cpp:15:40: warning: operation on ‘test’ may be undefined [-Wsequence-point]
test= anotherInt>test ? test++ : 0;
^
为什么 C++ 在三元运算时给我警告,而不是常规的 if..else
语句?