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
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