#include<iostream>
#include <string.h>
using namespace std;
int f1(int a, int b)
{
int c;
c = b % 2;
return a + c;
}
int f2(int a, int b)
{
int c;
a += a; b += b;
cout << "f1之前" << endl;
cout << "a:"<<a <<endl<<"b:"<< b<<endl;
cout << "a+b:" << a + b << "++b:" << ++b<<endl;
c = f1(a + b, ++b);
return c;
}
int main()
{
int a = 3, b = 4;
cout << f2(a, b);
return 0;
}
```
你可以加一个断点,然后去调试程序。像这样:
emm对于你的问题,在调试的过程中可以看出,两处a+b和++b 。他们的调用次序都是先++b再 a+b.
c = f1(a + b, ++b);
实参传递从右到左,先++b,再a+b
a=3+3 b=4+4
a=6 b=8+1
a+b=15