C++ 引用()
#include <iostream>
void sort(int &a, int &b)
{
if (a>=b)
{
return;
}
if (a<b)
{
int temp = a;
a = b;
b = temp;
}
}
?
int main(int argc, _TCHAR* argv[])
{
int a_=2, b_=4;
sort(a_, b_);
std::cout << a_ << " : " << b_ <<std::endl; //輸出結果:4 :2
return 0;
}
注:引用可在函數內部改變變量的值,函數返回可繼續使用改變后的值。
轉載于:https://www.cnblogs.com/wuchunming/p/3792746.html
總結
- 上一篇: linux下能ping ip不能ping
- 下一篇: debian 安装curl 很简单的一步