S
sugaray
I don't get why the correct way to allocate memory space for
3d-array should be like this in C++:
long (*ptr)[10][15];
ptr=new long[5][10][15];
and when deallocation
delete[] ptr;
Why declare the last two dimensions (*ptr)[10][15] first ?
Why not
long (*ptr)[5][10];
or
long *ptr=new long[5][10][15];
And why deallocate an 3d-array only use
delete[] ptr;
not
delete[][][] ptr;
Can anybody shed some light on the questions above ?
I'm new to C++ and is eager to get a better understanding of it,
Your help would be appreciated. Thanx in advance
Gary.
3d-array should be like this in C++:
long (*ptr)[10][15];
ptr=new long[5][10][15];
and when deallocation
delete[] ptr;
Why declare the last two dimensions (*ptr)[10][15] first ?
Why not
long (*ptr)[5][10];
or
long *ptr=new long[5][10][15];
And why deallocate an 3d-array only use
delete[] ptr;
not
delete[][][] ptr;
Can anybody shed some light on the questions above ?
I'm new to C++ and is eager to get a better understanding of it,
Your help would be appreciated. Thanx in advance
Gary.