📜  c++ 分配和释放动态二维数组 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:56.879000             🧑  作者: Mango

代码示例1
// allocate
int** matrix = new int*[rowCount];
for(int i = 0; i < rowCount; i++)
    matrix[i] = new int[colCount];

// free
for(int i = 0 ; i < rowCount; i++)
    delete[] matrix[i];    // delete array within matrix
delete[] matrix;    // delete actual matrix