#include<iostream>
using namespace std;
void swa(int *&_a, int *&_b)
{
int *temp;
temp = _a;
_a = _b;
_b = temp;
}
int main()
{
int a, b;
cin >> a >> b;
int *p1 = &a, *p2 = &b;
swa(p1, p2);
cout << *p1 << *p2 << endl;
cout << a << b << endl;
system("pause");
return 0;
}
请教楼主,为什么*p1和*p2换了,而a和b的值没有换呢?