From: temujin Newsgroups: comp.os.msdos.djgpp Subject: Re: Dynamic Arrays and C++ Date: Thu, 09 Jul 1998 20:51:23 -0400 Organization: Sentex Communications Lines: 22 Message-ID: <35A5658B.4E09@sentex.net> References: <6o0ck8$hs0$1 AT news DOT bctel DOT net> NNTP-Posting-Host: 209.112.40.47 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Endlisnis wrote: > > ->>Ok, I don't usually post here, but I've run out of options. I've been > ->>trying to figure out why I'm getting an error on this line of code: > ->> > ->> int *test = new int[8][8]; > You can't dynamically allocate a multi-dimensional arrays in C++. > You could say: > int* test = new int[64]; > And then use test[x*8+y] to resolve test[x][y]. > Or, if the dimensions are constants, don't dynamically allocate. > > Endlisnis > [I have a pyramid of wingyness] If you *MUST* use dynamic arrays and want to do it with OBJECTS/structures you have to remember to WHATEVER **myarray=malloc...... Have to have the double pointer thing to make it an array of pointers which point to objects. With just *myarray you create an array of unique and seperate objects.