-
create array with "new"
hi,
i can create an array that way :
int *ptrArray = new int[5] //array with 5 elements
but i cant create a bidimensional array this way. why? any help?
int *ptrArray = new int[5][5] //array with 25 elements
because the compiler generate the following error message:
C:\programas c++\ejer8_12\arreglos2.cpp(12) : error C2440: '=' : cannot convert from 'int (*)[1]' to 'int *'
please esxcuse my poor english
-
It's just a matter of getting the type correct
int (*ptrArray)[5] = new int[5][5];
But this only works when all the minor dimensions are constant.
-