指针的小问题
#include<iostream>using namespace std;
void swap(int *x,int *y);
int main(){
int x = 10;
int y = 20;
cout <<"Before swap, x ="<<x<<"y ="<<y<<endl;
swap(&x,&y);
cout <<"After swap, x ="<<x<<"y="<<y<<endl;
return 0;
}
void swap(int *x,int *y){
int *t = x;
x=y;
y = t;
}
为什么没有实现交换数据的功能??