Jos Timanta Tarigan wrote:
> hi, 
> im currently try to build a 3d array (array with three index) but the size is 
> 'user defined'. 
> so in the header file, i declare a pointer to pointer to pointer to int 
> int *** array;
> but im confused how to set it in the cpp file (setting the data). i've tried 
> this: 
> objectMapList = new int[xRes][yRes][squareLimit];
> with xRes, yRes, and squareLimit is a user defined variable. but it does not 
> work. any idea?
>   

When declaring a multi-dimensional array, all but the final array size 
must be static. To declare an array where all lengths are variable, you 
have to allocate the first array, then allocate each element of the 
second, etc.

Multidimensional arrays hurt my brain. Someone else can probably give an 
example. My solution: use objects and classes, and try to make each one 
as simple as possible.

-- 
John Gaughan
http://www.jtgprogramming.org/

Reply via email to