I want to dynamically allocate int Q[L+1][M+1]. I tried the following.
How to fix it?
int **Q = new int*[L+1]; // allocate the rows
for (i = 0; i < (L+1); i++) // now allocate the columns
*Q[i] = new int[M+1];
The error: cannot convert from 'int *' to 'int'
P********e 发帖数: 2610
2
int **Q = new int*[L+1]; // allocate the rows
for (i = 0; i < (L+1); i++) // now allocate the columns
Q[i] = new int[M+1];
【在 c**********e 的大作中提到】 : I want to dynamically allocate int Q[L+1][M+1]. I tried the following. : How to fix it? : int **Q = new int*[L+1]; // allocate the rows : for (i = 0; i < (L+1); i++) // now allocate the columns : *Q[i] = new int[M+1]; : The error: cannot convert from 'int *' to 'int'
c**********e 发帖数: 2007
3
Thanks a lot.
【在 P********e 的大作中提到】 : : int **Q = new int*[L+1]; // allocate the rows : for (i = 0; i < (L+1); i++) // now allocate the columns : Q[i] = new int[M+1];