作者ccpz (OoOoOo)
看板TransCSI
标题Re: [问题] 关於call by value/result
时间Sun May 20 08:27:57 2007
※ 引述《x0315b100 (飞来飞去)》之铭言:
: 请问各位大大...
: call by value 和 call by value/result
: 差在哪呢??
: C语言中应该怎麽写call by value/result呢??
: 还是C语言中根本就没有...call by value/result
: 希望大大可以用真实小程式解释@@"
: 麻烦了...
现在 C/C++ 都没有支援
这方法有点像 call by value/reference 的综合体
她传reference过去的时候会另外复制一份, 但是在回传时
会把复制回去原来的变数盖掉,用 c 写大概像这样吧 @@
void add(int &a,int &b)
{
int c=a;
int d=b;
c=c+d;
a=c;
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.113.92.1