指针和引用

void swapint(int &a,int &b)
{
    int temp;
    temp=a;
    a=b;
    b=temp;
}

c++自动把x,y的地址作为参数传递给swapint函数

int a = 1;
int &b = a;

b = 2;
printf("a = %d
", a);      //2
int a = 1;
int *b = &a;

*b = 2;
printf("a = %d
", a);      //2
原文地址:https://www.cnblogs.com/zhangxuechao/p/11709964.html