On Tue, 29 Jul 2003 12:13:34 +0200, "Dabroz" <th********@wp.pl> wrote:
can i allocate memory in multidimensional arrays by new?
Yes.
for example:
int* something;
something=new int[20][20][20];
it doesn't work! how i can make that?
It does not compile because the type of the 'new' expression is
not
int*
but
int (*)[20][20]
Declare your pointer as
int (*something)[20][20];
and it will compile.
But better, if you absolutely must program at the lowest
level instead of using the standard library, 'typedef' like so:
int main()
{
struct Tensor
{
int elem[20][20][20];
};
Tensor* t = new Tensor;
t->elem[1][2][3] = 666;
delete t;
}
General recommendation is, however, to use standard library and
boost collection classes.
Hth.