本文介绍了什么是“删除”的数组形式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我用数组名作为指针编制了code,我使用删除数组名删除
,我得到了一个警告,有关删除阵列时不使用数组形式(我不记得确切的写法)。
When I compiled a code using the array name as a pointer, and I deleted the array name using delete
, I got a warning about deleting an array without using the array form (I don't remember the exact wording).
基本code是:
int data[5];
delete data;
那么,什么是删除阵列形式?
So, what's the array form of delete?
推荐答案
中删除的磁盘阵列形式是:
The array form of delete is:
delete [] data;
编辑:但是,正如其他人所指出的那样,你不应该调用删除
像这样定义的数据:
But as others have pointed out, you shouldn't be calling delete
for data defined like this:
int data[5];
您应该只调用它,当你使用分配内存新
是这样的:
You should only call it when you allocate the memory using new
like this:
int *data = new int[5];
这篇关于什么是“删除”的数组形式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!