看来你可以使用参考来做到这一点。在C++中,也就是说,C中没有引用。
#include <iostream>
int a = 0;
int& swap(int x, int y) {
return a;
}
int main()
{
int x = 0, y = 0;
swap(x, y) = 100;
std::cout << "a is " << a << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2358 次 |
| 最近记录: |