析构函数delete
时间: 2023-08-04 21:03:12 浏览: 94
为何要虚析构函数.docx
析构函数和delete之间的关系是:delete操作会在释放对象的内存空间之前调用对象的析构函数。当使用delete释放堆上创建的对象时,程序会执行该对象的析构函数,以释放对象所占用的资源。而对于在栈上创建的对象,当作用域结束时,对象会自动调用析构函数进行资源的释放。所以,delete操作是析构函数执行的充分条件,但并不是必然联系。\[1\]\[2\]\[3\]
#### 引用[.reference_title]
- *1* *2* [关于delet和析构函数](https://blog.csdn.net/lplp90908/article/details/50003621)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [C++析构函数和delete关系](https://blog.csdn.net/Taynpg/article/details/109245219)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文