为什么析构函数不是隐式调用放置新的“? [英] why destructor is not called implicitly in placement new"?

查看:102
本文介绍了为什么析构函数不是隐式调用放置新的“?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如本网站所提及...
http://www.parashift.com/c++-faq-lite/dtors.html#faq-11.10
但是我没有找到原因,为什么我们应该显式调用desturctor?

As referenced in this site... http://www.parashift.com/c++-faq-lite/dtors.html#faq-11.10 But i did not find the reason, why we should explicitly call the desturctor?

推荐答案

通常, new ed对象在 delete 被调用。删除从来没有调用为放置new,所以你必须弄清楚什么时候自己破坏对象,并明确这样做。

Normally, newed objects are destructed when delete is called. delete is never called for placement new, so you have to figure out when to destruct the object yourself, and do so explicitly.

这篇关于为什么析构函数不是隐式调用放置新的“?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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