boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - one question about overloading operator delete
相关主题
C++高手请进,内存管理问题
请教 C++的一个困惑 (operator delete)
C++ delete
delete一问
请问delete的问题
请教一下,exception时,destructor一定会被调用么?
What is wrong?
one question about operator delete
求教new delete 在c++中的重载
问个C++中重复删除指针的问题
相关话题的讨论汇总
话题: delete话题: operator话题: overload话题: when
进入Programming版参与讨论
1 (共1页)
g**********1
发帖数: 1113
1
When I try to overload operator delete in C++, I need to delete some void *.
Thus I will get warning when I compile the source code. I wonder if there
is any way to avoid the warning.
Thank you.
t****t
发帖数: 6806
2
use ::operator delete() to delete void*, if you used ::operator new to
allocate it.
use free() to delete void*, if you used malloc to allocate it.
how did you get the memory? if you overload operator delete, you usually
have to overload operator new as well. in most cases they have to appear
together.
if you don't know what you are doing, better leave them alone. it's very
easy to mess up.

*.

【在 g**********1 的大作中提到】
: When I try to overload operator delete in C++, I need to delete some void *.
: Thus I will get warning when I compile the source code. I wonder if there
: is any way to avoid the warning.
: Thank you.

g**********1
发帖数: 1113
3
When I read the book: thinking in C++. The chapter about overload new and
delete operators. I practice the code and found the warning. Also this book
metions that not deleting void *. Thus I want to know how to avoid this
problem.
Thank you.

【在 t****t 的大作中提到】
: use ::operator delete() to delete void*, if you used ::operator new to
: allocate it.
: use free() to delete void*, if you used malloc to allocate it.
: how did you get the memory? if you overload operator delete, you usually
: have to overload operator new as well. in most cases they have to appear
: together.
: if you don't know what you are doing, better leave them alone. it's very
: easy to mess up.
:
: *.

1 (共1页)
进入Programming版参与讨论
相关主题
问个C++中重复删除指针的问题
new and delete in c++
一个interview问题,关于内存泄漏
new一定要和delete配对吗?
这样会不会造成memory leak?
linux 能查到 deleted file list 吗
Why my new or delete operator would fail?
C++求助: New/Delete in Multidimensioned array
C++ pointer problem
请教一个C++有关的编译问题
相关话题的讨论汇总
话题: delete话题: operator话题: overload话题: when