I wouldn't try.
I would create a single dimensioned array and use arithmatic to calculate the correct index values.
For instance suppose you want the equivilent of
int array[X][Y][Z];
Where X, Y and Z represent any (sensible) integer value.
This actually has X*Y*Z entries so I would allocate a single dimensioned array with this many entries
int *array = new int[X*Y*Z];
and write a function to calculate the array index give x, y and z
-
inline unsigned arrayIX(unsigned x, unsigned y, unsigned z)
-
{
-
assert(x<X);
-
assert(y<Y);
-
assert(z<Z);
-
-
return (x*Y*Z+y*Z+z);
-
}
-
The I can use the function to access array
array[arrayIX(1,4,6)];
since arrayIX is inline and is doing a similar calculation to the one that would have to be done anyway there is not going to be a big difference in performance (especially for an optomising compiler)
and the new/delete process is much easier since it only envolves 1 new and 1 delete.