我知道这个问题可能以前被问过,但是在这个上下文中我不明白:
这里是我试图检查的代码,我会加上注释,请告诉我哪里出了问题
int **A; // declaring a pointer to a pointer
A = new int*[n]; // assigning that pointer to a newly-allocated
// space (on the heap) for an array
// of [size n] of pointers to integers
for (i = 0; i < n; ++i) // looping from 0 to n-1
A[i] = new int[n]; // assigning each slot's pointer to a
// new array of size n?
for (i = 0; i < n; ++i) // loop through all the rows
for (j = 0; j < n; ++j) // loop through each column for the current row
A[i][j] = 0; // assign the value to 0
请告诉我哪里出错了。我对
A = new int*[n];
一无所知,只是想通过常识弄清楚,但遇到麻烦了。谢谢!