交换没有临时变量,警告错误,为什么?

时间:2018-03-30 12:30:19

标签: c++ compiler-warnings swap

警告:'left'上的操作可能未定义[-Wsequence-point] right = right + left - (left = right);

{
    int right = 5, left = 14;
    std::cout << right << " " << left << std::endl;
    right = right + left - (left = right);
    std::cout << right << " " << left << std::endl;
}

0 个答案:

没有答案