Path: utzoo!attcan!uunet!olivea!decwrl!elroy.jpl.nasa.gov!usc!zaphod.mps.ohio-state.edu!rpi!bu.edu!m2c!jjmhome!zinn!nuucp From: mjv@objects.mv.com (Michael J. Vilot) Newsgroups: comp.lang.c++ Subject: Re: Overloaded operator new VS. inheritance Message-ID: <1149@zinn.MV.COM> Date: 27 Jan 91 19:07:11 GMT Sender: nuucp@zinn.MV.COM Lines: 18 Tom Keffer commented on the subtleties induced by inheriting operators new and delete, and proposed a language extension to deal with the problem. First, let me point out that the problem he cited does not require a language extension to solve it. Tom's example failed to take advantage of an existing feature of overloading operator delete: specifically, the form taking a second argument of type size_t (ARM, p. 283): void operator delete(void*, size_t); If the classes involved in inheritance provide a virtual destructor, the right size should get passed to delete. Second, I applied exactly this technique to the Managed and Controlled forms of the C++ Booch Components library. It works just fine, at the cost of a slightly more sophisticated free list manager (it keeps the free lists sorted by size). -- Mike Vilot, ObjectWare Inc, Nashua NH mjv@objects.mv.com (UUCP: ...!decvax!zinn!objects!mjv)