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. : : *.
|
|