operator delete []在标准中有一个void *作为参数,所以你没事。 operator delete[] has a void* as parameter in the standard, so you''re fine. 对不起,这是一个不正确的推理。 /> 标准将此定义为未定义行为,如果某人不应该看到这个含义,它会在说明73中明确指出void *: [上下文:删除数组]" ...使用 类型void *的指针无法删除对象因为..."。 - 答:因为它弄乱了人们通常阅读文字的顺序。 问:为什么这么糟糕东西? A:热门发布。 问:usenet和电子邮件中最烦人的是什么?Sorry, that''s an incorrect inference.The standard defines this as Undefined Behavior, and in case somebody shouldnot see that implication, it states that explicitly for void* in note 73:[context: delete array] "... an object cannot be deleted using a pointer oftype void* because ...".--A: Because it messes up the order in which people normally read text.Q: Why is it such a bad thing?A: Top-posting.Q: What is the most annoying thing on usenet and in e-mail? 对不起,这是一个不正确的推理。 标准将此定义为未定义行为,如果某人不应该看到这种含义,它会在注释73中明确指出void *: [context:delete array ]...使用类型void *的指针无法删除对象因为...。 Sorry, that''s an incorrect inference. The standard defines this as Undefined Behavior, and in case somebody should not see that implication, it states that explicitly for void* in note 73: [context: delete array] "... an object cannot be deleted using a pointer of type void* because ...". 我认为指的是一个虚空的数组是不可能的(大小为0,类似的原因,为什么一个(空的)实例化对象的大小至少为 1);因此你不能删除[]一个真正的空白*。但在max'的情况下, 基础数据实际上是另一种类型(int *)。运算符delete [] 取无效*,所以无论你传递什么指针,它都会在运算符运行之前首先转换为 void *。 /> - 问候, Ferdi Smit(理学硕士) 电子邮件: Fe********@cwi.nl 房间:C0.07电话:4229 INS3可视化和3D界面 CWI荷兰阿姆斯特丹I think that refers to an array of void which is impossible (size 0, asimilar reason to why an (empty) instantiated object has size at least1); and thus you can''t delete[] a true void*. But in max''s case theunderlying data is in fact of another type (int*). The operator delete[]takes a void*, so whatever pointer you pass it, it will be cast to avoid* first before the operator runs anyway.--Regards,Ferdi Smit (M.Sc.)Email: Fe********@cwi.nlRoom: C0.07 Phone: 4229INS3 Visualization and 3D InterfacesCWI Amsterdam, The Netherlands 这篇关于删除POD的[]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!