→ eass:大哥...謝啦!! 推140.112.242.193 11/02
※ 引述《eass (電機系籃台大制霸)》之銘言:
: call by value和call by reference
: 有什麼差?
: 兩個要怎麼弄才會不一樣
call by value
{
int a=2,b=4,c;
...
...
c=f(a,b);
...
...
}
int f(int d, int e)
{
d*=2;
e*=3
return e*d;
}
=>
a=2
b=4
c=48
================================
call by ref
{
int a=2,b=4,c;
...
..
c=f(&a,&b)
}
int f(int& d,int& e)
{
d*=2;
e*=3;
return d*e;
}
=>
a=4
b=12
c=48
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.166.91.117
※ 編輯: deathcustom 來自: 218.166.91.117 (11/01 21:02)