Mail Archives: djgpp/1997/02/22/23:14:36
Hades wrote:
>
> #include <iostream.h>
>
> 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. |
---------------------------------------------------------------------
- Raw text -