On Mon, 01 Nov 2004 23:02:21 GMT, Robert Harris
<ro*****************@blueyonder.co.uk> wrote:
Richard Hayden wrote:
<snip>
I thought that multi-dimensional arrays were implemented as arrays of
pointers to arrays of pointers?
No (unlike Pascal). They are implemented as "flat" arrays: se section
6.5.2.1 of the standard.
Correct about C, or nearly so; they are actually array of array, which
works out (effectively) to row-major consecutive memory. But this is
not different from Pascal, which like most HLLs has multidim arrays in
the obvious fashion -- although it tries harder than C or at least
typical C implementations to prevent out-of-bounds subscripting (or
equivalently in C only pointer arithmetic) which is the only way a
program can actually see this.
Aside from C's predecessors B and BCPL, now almost entirely vanished,
the only language I know of that requires array of pointer to array
etc. is Java, although the pointers (and elements) are "Object"s that
are implicitly dereferenced. C++ has C-equivalent arrays including
multidim, but also std::vector which if nested becomes array of
(hidden) pointer to array etc.
- David.Thompson1 at worldnet.att.net