malloc和operator new之间的差异.. [英] differences between malloc and operator new..

查看:78
本文介绍了malloc和operator new之间的差异..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..

我很抱歉我最近提出了这么多问题.. :)


我'' m仍然对malloc和operator new之间的差异感到困惑。

我知道当我们使用类对象并使用operator new / delete时,

ctor和dtor

按预期调用,但malloc和free不会......


但是Herbal Sutter在他的热门书中提到''特殊的c ++'关于免费

存储

和堆..

他说他们是不同的,我们需要知道差异..


但我仍然对他们的不同感到困惑..

我原本以为新的和malloc都使用堆...


有人能澄清一下吗?

Hi..
I''m so sorry about that I''ve postes so many questions recently.. :)

I''m still confused about the differences between malloc and operator new..
I know that when we work with class object and use operator new/delete, the
ctor and dtor
get called as expected, but malloc and free do not..

But Herbal Sutter mentioned in his greate book ''exceptional c++'' about free
storage
and heap..
He said they are differenct and we need to know the differences..

But I''m still confused about they are different..
I''ve thought actually both new and malloc use heap..

can some clearify me?

推荐答案



" BekTek" <是**** @ gmail.com>在消息中写道

news:ZNsqd.2517

"BekTek" <be****@gmail.com> wrote in message
news:ZNsqd.2517


wr6.2059@trnddc04 ...
wr6.2059@trnddc04...
嗨..
但是Herbal Sutter在他的书中提到了特殊的c ++关于免费的
Hi.. But Herbal Sutter mentioned in his greate book ''exceptional c++'' about free




我不认为Herb是草药的缩写。在这种情况下;-)


Jonathan



I don''t think "Herb" is short for "Herbal" in this case ;-)

Jonathan




" Jonathan Turkanis" < TE ****** @ kangaroologic.com>在消息中写道

news:30 ************* @ uni-berlin.de ...

"Jonathan Turkanis" <te******@kangaroologic.com> wrote in message
news:30*************@uni-berlin.de...

" BekTek" <是**** @ gmail.com>在消息中写道
新闻:ZNsqd.2517

"BekTek" <be****@gmail.com> wrote in message
news:ZNsqd.2517


这篇关于malloc和operator new之间的差异..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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