设为首页 加入收藏

TOP

Pass-by-value Pass-by-reference Pass-by-value-result Pass-by-name
2014-11-24 01:01:25 来源: 作者: 【 】 浏览:8
Tags:Pass-by-value Pass-by-reference Pass-by-value-result Pass-by-name

Consider the following program written in C-like syntax (but not exactly C language):
void swap(int a, int b) {
int temp;
temp = a;
a = b;
b = temp;
}
void main( ) {
int value = 1, list[5] = {1, 3, 5, 7, 9}; /* list[0] = 1, list[1] = 3, … */
swap(value, list[value]); /* here */
}
For each of the following parameter-passing methods, what are all of the values of the
variables value and list after the call to ‘swap’ (at the point marked ‘here’) Justify
your answer.
(example answer: value = 1, list = {1, 3, 5, 7, 9}).
(a) Pass-by-value
(b) Pass-by-reference
(c) Pass-by-value-result (Assume address binding at entry)
(d) Pass-by-name


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇一套SQL经典的面试题及答案 下一篇程序员技术类面试、笔试题汇总

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: