From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: compile error: char *frame_ptr = new char[20][20] ('X') Date: Sat, 22 Feb 1997 22:25:09 -0800 Organization: Two pounds of chaos and a pinch of salt Lines: 38 Message-ID: <330FE2C5.2F2@cs.com> References: <3316832f DOT 19841747 AT news DOT erols DOT com> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp103.cs.com 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 Hades wrote: > > #include > > main() > { > char *frame_ptr = new char[20][20] ('X'); > > delete[][] frame_ptr; > } > > ERROR message: > > initialization to 'char *' from 'char (*) [20]' > > 1) how did that happen? A two dimensional array must be referenced with double indirection, i.e.: char **frame_ptr = new char[20][20] ('X'); > 2) and when i free up the memory do i use: > > a) delete frame_ptr; > b) delete frame_ptr[]; > c) delete frame_ptr[][]; I'm not an expert with C++, but I am pretty sure that a) will work. b) and c) might work as well - the best way to find out is to test it. -- --------------------------------------------------------------------- | John M. Aldrich, aka Fighteer I | fighteer AT cs DOT com | | * Proud user of DJGPP! * | http://www.cs.com/fighteer | | ObJoke: If Bill Gates were a robber, not only would he | | shoot you, but he'd send you a bill for the bullets. | ---------------------------------------------------------------------