avatar
one more interview question# Programming - 葵花宝典
m*o
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.
avatar
m*t
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.

avatar
m*o
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]
avatar
m*t
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

avatar
m*o
5
not sure, just a interview question I got!
avatar
c*x
6
by value, - pass in parameter
by reference, - pass in referece
by value/
result, -return a result
by name -pass in an alias
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。