By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,134 Members | 1,942 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,134 IT Pros & Developers. It's quick & easy.

Overloading new[] and delete[]: how do they vary from new and delete?

P: n/a
I'm writing a memory manager and overloading the operators "::new" and
"::delete" I know this isn't always the smartest thing to do, but
regardless, I was wondering what sort of considerations I should be
making when writing the array-based versions "new[]" and "delete[]"
(in contrast to the single item "new" and "delete").

I know the fundamental issue between ensuring "new[]" is matched with
"delete[]" is making sure the destructor for each of the items in the
dynamically-allocated array is called (as opposed to just the first if
only "delete" were called). If I'm just getting a pointer to the
beginning of said array when "delete[]" is called, how do I handle
this properly?

Thanks in advance.

Dave
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 5 Aug 2003 20:22:36 -0700, ve*****@hotmail.com (HeroOfSpielburg) wrote:
I'm writing a memory manager
That's not a good idea except as an exercise.

To write a (useful) memory manager you need to really know
what you're doing.

Take a look in "Modern C++ Design" and in the Boost library.

...
If I'm just getting a pointer to the
beginning of said array when "delete[]" is called, how do I handle
this properly?


You don't. Your responsibility is not to call destructors but to
deallocate memory. Whatever the latter means in your code.

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.