删除[] [英] delete []

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

问题描述

大家好,

我记得删除[]是通过运算符重载实现的,但是我不是很清楚




任何人都可以推荐一些关于如何实现delete []的链接,以便

我可以学习并刷新我的记忆吗? :-)

提前感谢,

George

解决方案

George写道:


大家好,


我记得删除[]是通过运算符重载实现的,但我是

不太清楚。


任何人都可以推荐一些关于如何实现delete []的链接,以便

我可以学习并刷新记忆吗? :-)



George:


delete []调用数组中每个元素的析构函数,并且

然后释放内存。还有什么需要知道的?


-

David Wilkinson

Visual C ++ MVP


嗨大卫,

我的问题是如何实现默认删除和删除[]?以及如何/为什么

默认删除和删除[]适用于任何数据类型,例如,我们有一个

类Foo,即使我们没有实现删除和删除[]运算符在类中

Foo,我们仍然可以使用delete []来释放Foo

实例数组的内存。


你能帮忙描述一下delete []如何适用于任何数据类型吗?



std中有一些默认基类或一些默认的delete []实现命名空间?

问候,

乔治


" David Wilkinson"写道:


George写道:


大家好,

我记得delete []是通过运算符重载实现的,但我不是很清楚。


任何人都可以推荐一些关于delete []如何实现的链接,以便

我可以学习并刷新记忆吗? :-)



George:


delete []调用数组中每个元素的析构函数,并且

然后释放内存。还有什么需要知道的?


-

David Wilkinson

Visual C ++ MVP




" George" < Ge **** @ discussion.microsoft.com写信息

新闻:E0 ************************ ********** @ microsof t.com ...


大卫


我的问题是如何实现默认删除和删除[]?并且

如何/为什么

默认删除和删除[]适用于任何数据类型,例如,我们有

a

类Foo,即使我们没有实现删除和删除[]运算符在



Foo,我们仍然可以使用delete []来释放内存一系列Foo

实例。


你能帮忙描述一下delete []如何适用于任何数据类型吗?


std命名空间中有一些默认基类或一些默认的delete []实现




任何没有提供new和delete定义的类型(以及

数组变体)将使用属于到基类(如果它有
它们)或者在全局(只是:: not :: global)命名空间中定义。


许多运行时库提供不同的定义,可以调试

跟踪分配等。


如果你告诉我们你正在使用什么库,可能有人可以告诉你什么

文件的默认定义为:: operator []


>


问候,

乔治


" David Wilkinson"写道:


> George写道:


大家好,


我记得删除[]是通过运算符重载实现的,但

我是

不太清楚。


任何人都可以推荐一些关于如何实现delete []的链接



我可以学习并刷新我的记忆吗? :-)


George:

delete []调用数组中每个元素的析构函数,然后
释放内存。你还需要知道什么?

-
David Wilkinson
Visual C ++ MVP



Hello everyone,
I remembered delete[] is implemented through operator overloading, but I am
not quite clear.

Could anyone recommend some links about how delete[] is implemented so that
I can learn and refresh my memory? :-)
thanks in advance,
George

解决方案

George wrote:

Hello everyone,
I remembered delete[] is implemented through operator overloading, but I am
not quite clear.

Could anyone recommend some links about how delete[] is implemented so that
I can learn and refresh my memory? :-)

George:

delete [] calls the destructor of each of the elements in the array, and
then frees the memory. What else do you need to know?

--
David Wilkinson
Visual C++ MVP


Hi David,
My question is how default delete and delete[] are implemented? And how/why
default delete and delete[] works for any data types, for example, we have a
class Foo, even if we do not implement delete and delete[] operator in class
Foo, we still could use delete[] to free the memory of an array of Foo
instances.

Could you help to describe how delete[] works for any data type please?
There are some default base class or some default delete[] implementation in
std namespace?
regards,
George

"David Wilkinson" wrote:

George wrote:

Hello everyone,
I remembered delete[] is implemented through operator overloading, but I am
not quite clear.

Could anyone recommend some links about how delete[] is implemented so that
I can learn and refresh my memory? :-)


George:

delete [] calls the destructor of each of the elements in the array, and
then frees the memory. What else do you need to know?

--
David Wilkinson
Visual C++ MVP



"George" <Ge****@discussions.microsoft.comwrote in message
news:E0**********************************@microsof t.com...

Hi David,
My question is how default delete and delete[] are implemented? And
how/why
default delete and delete[] works for any data types, for example, we have
a
class Foo, even if we do not implement delete and delete[] operator in
class
Foo, we still could use delete[] to free the memory of an array of Foo
instances.

Could you help to describe how delete[] works for any data type please?
There are some default base class or some default delete[] implementation
in
std namespace?

Any type that doesn''t provide its own definition of new and delete (and the
array variations) will use the ones belonging to the base class (if it has
them) or else defined in the global (just :: not ::global) namespace.

Many runtime libraries provide different definitions that may do debug
tracing of allocations, etc.

If you tell us what library you are using probably someone can tell you what
file has the default definition of ::operator[]

>

regards,
George

"David Wilkinson" wrote:

>George wrote:

Hello everyone,
I remembered delete[] is implemented through operator overloading, but
I am
not quite clear.

Could anyone recommend some links about how delete[] is implemented so
that
I can learn and refresh my memory? :-)


George:

delete [] calls the destructor of each of the elements in the array, and
then frees the memory. What else do you need to know?

--
David Wilkinson
Visual C++ MVP



这篇关于删除[]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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