Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!orion.oac.uci.edu!eapu034 From: eapu034@orion.oac.uci.edu (Carl F. Edman) Newsgroups: comp.lang.c++ Subject: Re: parameter[][] Message-ID: <26B9BF5A.7291@orion.oac.uci.edu> Date: 3 Aug 90 18:15:53 GMT References: <1545@m1.cs.man.ac.uk> Reply-To: eapu034@orion.oac.uci.edu (Carl F. Edman) Organization: University of California, Irvine Lines: 35 In article <1545@m1.cs.man.ac.uk> jk@cs.man.ac.uk (John Kewley ICL) writes: >One of our staff is whingeing about having to specify the size of all >dimensions for a multidimensional array (beyond the first that is). > >Can anyone give me some good reasons why this is, so I can placate him. >He claims that it can be done in C so why can't it be done in C++. >-- > J.K. > For starters: This is in no way possible in C or C++ and couldn't be as the following example might illustrate. In one source-file: char array[4][6][8]; In another source-file: extern char array[][][]; // Using NO dimensional specifiers array[3][5][7]='a'; Now, how should the compiler of the second source-file find out where element a[3][5][7] is in respect to the base-address pointed to by a, without knowing the dimensions of the array ? In the example the element would be the (3*6+5)*8+7st (counting from zero) of the array. As you see the knowing the exact dimensions of the array is neccessary for the second file to compile thus: No there is no way to use a declaration like the one above. Carl Edman Theorectial Physicist,N.:A physicist whose | Send mail existence is postulated, to make the numbers | to balance but who is never actually observed | cedman@golem.ps.uci.edu in the laboratory. | eapu034@orion.oac.uci.edu