您的位置:首页 > 其它

编引用之swap()---高手帮忙写下笔记,还有解决一下问题,谢谢了

2008-12-03 16:36 471 查看
#include <iostream>

using namespace std;

void swap(int &x,int &y);

int main()

{

int x=5,y=10;

cout<<"main.before swap. x: "<<x<<" y: "<<y<<endl;

swap(x,y); //为什么和原型不一样哦????

cout<<"main.after swap, x: "<<x<<" y: "<<y<<endl;

return 0;

}

void swap(int &rx,int &ry) //这里到底是什么意思??

{

int temp;

cout<<"swap.before swap. rx: "<<rx<<" ry: "<<ry<<endl;

temp=rx;

rx=ry;

ry=temp;

cout<<"swap.before swap. rx: "<<rx<<" ry: "<<ry<<endl;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐