```
- 函数中使用引用技术:
void swap(int &n1, int &n2)
{
int temp = 0;
temp = n1;
n1 = n2;
n2 = temp;
}
int main()
{
int a = 23;
int b = 78;
swap(a, b);
}
——————————————————————--
代码:
#include
using namespace std;
void swap (int &n1,int &n2)
{
int temp=0;
temp=n1;
n1=n2;
n2=temp;
}
int main(int argc, char *argv[])
{
int a=23;
int b=20;
swap(a,b);
cout<< a <<"-----"<< b<< endl;
return 0;
}