Is it possible to dynamicaly allocate space for a multidimentional array.
Something like:
or something like that?Code:int* var = new int* [2][2];
Is it possible to dynamicaly allocate space for a multidimentional array.
Something like:
or something like that?Code:int* var = new int* [2][2];
not quite, here's an example
Code:int ** ptr = new int * [2]; for (int i = 0; i < 3; i++) ptr[i] = new int [2];
Thanks, that was really helpful, I suspected i would have to have pointer point to a pointer point to a memory address, but I though maybe there was an easier way :-\
Thanks a lot.
http://www.parashift.com/c++-faq-lit...html#faq-16.16Originally Posted by mrafcho001
Or a vector of vectors?
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
> but I though maybe there was an easier way
There is, if all your minor dimensions are constant.
For example
int (*var)[2] = new int[6][2];