当前在线人数16254
首页 - 分类讨论区 - 电脑网络 - 葵花宝典版 -阅读文章
未名交友
[更多]
[更多]
文章阅读:Re: 谁能给个总结?Re: c语言,2d数组传递wenti
[同主题阅读] [版面: 葵花宝典] [作者:crystalike] , 2004年09月02日14:42:50
crystalike
进入未名形象秀
我的博客
[上篇] [下篇] [同主题上篇] [同主题下篇]

发信人: crystalike (St. Sevilla), 信区: Programming
标  题: Re: 谁能给个总结?Re: c语言,2d数组传递wenti
发信站: Unknown Space - 未名空间 (Thu Sep  2 14:49:36 2004), 转信

actually the original problem is deviated and buried somehow.

1. c/c++ always passes array by pointer of the contained elem but never by value.
   of course you can use vector to pass by value but its deemed a bad approa
ch.

2. 1-D array can be converted to type * implicitly except in the case when a
const ref of array is used.

3. n-d array is a bit tricky. note int ** is different from int[][i] and int
(*)[i] (latter 2 are the same). so for N-D array you
either
1. void foo ( int [][5]);
   int i[2][5];
   foo (i)
or
2. void foo (int ** );
   // do dynamic allocation for a int ** to simulate a 2-d array
   // call foo with int ** as aug.


【 在 thrust (哼哼的多隆猪) 的大作中提到: 】
: see 9287 and the discussion follows.
: 【 在 bornforfree (灵魂在飞翔) 的大作中提到: 】
: : Fact1: The sample code below won't pass compiler in VC,
: : Fact2: The sample code below can't pass compiler in gcc,
: : The reason is: ???
: : Thanks,


--
※ 来源:.Unknown Space - 未名空间 mitbbs.com.[FROM: 129.59.]

[上篇] [下篇] [同主题上篇] [同主题下篇]
[转寄] [转贴] [回信给作者] [修改文章] [删除文章] [同主题阅读] [从此处展开] [返回版面] [快速返回] [收藏] [举报]
 
回复文章
标题:
内 容:

未名交友
将您的链接放在这儿

友情链接


 

Site Map - Contact Us - Terms and Conditions - Privacy Policy

版权所有,未名空间(mitbbs.com),since 1996