删除静态数组在C ++中 [英] Delete static array in C++

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

问题描述

我写了一些code是这样的:

 ,而(真){
    int数组[5];
    // 做一点事
}

有关循环的每个回合的数组是一个新的数组,我是否需要删除的磁盘阵列中循环的结束?


解决方案

  

我是否需要删除的磁盘阵列中循环的结束?


后,您不必删除它,因为阵列具有自动存储时间。它将被释放时熄灭每个while循环。

您需要调用删除[] /新[] 删除/新成对出现的。

I am writing some code like this:

while(true) {
    int array[5];
    // do something
}

For each turn of loop the array is a new array, Do I need to delete the array in the end of loop?

解决方案

Do I need to delete the array in the end of loop?

No, you don't need to delete it because array has automatic storage duration. It will be released when goes out of each while loop.

You need to call delete [] / new [], and delete / new in pairs.

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

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