Why should we overload/override new and delete?
Possible Duplicate:
Any reason to overload global new and delete?
Why should we overload/override new and delete in C++?
Give me an example of situation in which we should overload/override new, new[], delete or delete[].
This sounds a bit like a homework assignment. Nevertheless, here are two uses off the top of my head:
valgrind
to track memory leaks. allocator
for this, though. To provide your implementation of allocating/deallocating memory. new/delete are very general. When you know how your application is going to use memory you can provide more efficient version of new/delete. That would be very simple for example if you used a lot of small object.
Another usage would be to provide memory leak detection.
That's not very often used mechanism - at least in my experience.
链接地址: http://www.djcxy.com/p/73042.html上一篇: 在控制结构块中定义变量
下一篇: 为什么我们应该重载/覆盖新的和删除?