发信人: 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
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
1. void foo ( int );
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.]