Well, there are two things to consider with your example code:
- The order of evaluation of function arguments is unspecified, so whether
++a
or a++
is evaluated first is implementation-dependent.
- Modifying the value of
a
more than once without a sequence point in between the modifications results in undefined behavior. So, the results of your code are undefined.
If we simplify your code and remove the unspecified and undefined behavior, then we can answer the question:
void xyz(int x) { }
int a = 1;
xyz(a++); // 1 is passed to xyz, then a is incremented to be 2
int a = 1;
xyz(++a); // a is incremented to be 2, then that 2 is passed to xyz
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…