我有以下片段:
#include <iostream>
void test(int arg_1, int arg_2, int arg_3, int arg_4)
{
std::cout << arg_1 << ", " << arg_2 << ", " << arg_3 << ", " << arg_4 << std::endl;
}我运行了以下场景,但我无法理解它们。请解释一下。
案例-1:
int i;
i = 200;
test(i, i, i, i);案例1-产出:
200, 200, 200, 200案例-2:
int i;
i = 200;
test(i++, i++, i++, i++);案例2-产出:
203, 202, 201, 200案例-3:
int i;
i = 200;
test(i++, i+=10, i++, i++);案例3-产出:
212, 213, 201, 200案例-4:
int i;
i = 200;
test(i++, i++, i+=10, i++);案例4-产出:
212, 211, 213, 200案例-5:
int i;
i = 200;
test(i++, i++, i++, i+=10);案例-5-产出:
212, 211, 210, 213案例-6:
int i;
i = 200;
test(i++, i+=10, i++, i+=1);案例-6-产出:
212, 213, 201, 213案例1只是供参考,而案例2则很容易理解。但是从案例3到案例6;我不知道发生了什么。请解释一下这种行为。
此外,对此类行为是否有任何官方文件/参考文件?
发布于 2019-07-23 06:46:42
https://stackoverflow.com/questions/57158121
复制相似问题