m*******o 发帖数: 264 | 1 Write a simple procedure or function that will have four different effects,
depending on whether arguments are passed by value, by reference, by value/
result, or by name in whatever language you like. | m******t 发帖数: 4077 | 2 what does it mean by passing by name?
,
【在 m*******o 的大作中提到】 : Write a simple procedure or function that will have four different effects, : depending on whether arguments are passed by value, by reference, by value/ : result, or by name in whatever language you like.
| m*******o 发帖数: 264 | 3 Passed by name: the effect of a procedure call is as if the call were
replaced by the body of the procedure with the formal parameter names
replaced by the actual parameter names. eg.
integer procedure Sum(Exp, i, low, high)
integer Exp, i, low, high;
begin
integer s;
s:=0
for i:=low to high do
s:=s+Exp
return s;
end
Sum(A[j], j, 1, 10) ------> passed by name: s:=s+A[j] | m******t 发帖数: 4077 | 4 is this available in c/c++?
【在 m*******o 的大作中提到】 : Passed by name: the effect of a procedure call is as if the call were : replaced by the body of the procedure with the formal parameter names : replaced by the actual parameter names. eg. : integer procedure Sum(Exp, i, low, high) : integer Exp, i, low, high; : begin : integer s; : s:=0 : for i:=low to high do : s:=s+Exp
| m*******o 发帖数: 264 | 5 not sure, just a interview question I got! | c********x 发帖数: 84 | 6 by value, - pass in parameter
by reference, - pass in referece
by value/
result, -return a result
by name -pass in an alias |
|