差异i = i + 1 vs i ++

时间:2015-05-25 19:02:27

标签: c++

请考虑以下代码:

#include <iostream>

int main()
{
    int i = 1; 
    i = (i = i + 1) + 1;
    int j = 1;
    j = j++ + 1;
    std::cout << i << std::endl;  //3
    std::cout << j << std::endl;  //2
}

有什么区别?

0 个答案:

没有答案