如何在C ++中删除此二维动态数组 [英] How to delete this 2d dynamic array in c++

查看:145
本文介绍了如何在C ++中删除此二维动态数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

bool **arr=new bool* [row];
for(int i=0; i<9; i++)
{
    arr[i]= new bool[column];
}

我想删除此动态数组,因为它会导致我的RAM出现问题.

I want to delete this dynamic array because it cause a problem with my RAM.

推荐答案

您只需按照相反的顺序删除它即可:

You just delete in the reverse order it was allocated:

for(int i=0; i<9; i++) {
    delete [] arr[i];
}
delete[] arr;

这篇关于如何在C ++中删除此二维动态数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆