Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!csn!pikes!mercury.cair.du.edu!diana.cair.du.edu!ttoupin From: ttoupin@diana.cair.du.edu (Aerin) Newsgroups: comp.lang.c++ Subject: Re: Overloading new and delete Keywords: new,delete,overloading Message-ID: <1991Jun11.044126.6617@mercury.cair.du.edu> Date: 11 Jun 91 04:41:26 GMT References: <10961@rama.UUCP> Sender: news@mercury.cair.du.edu (netnews) Organization: University of Denver Lines: 48 In article <10961@rama.UUCP> Lyndon VanWagner writes: >According to pg. 164, and 262-266 of C++ Primer by >Stanley B. Lippman, one can overload the new and delete operators. >I have heard some references on the net about doing this in C++ 2.0+ . >Were these just rumors, or can we still do this? Cf. E&S, pp. 282-4. Paraphrasing: operators new and delete can be overloaded. With operator new, one must specify have at least one argument void *operator new(size_t __size Other arguments must be specified, but an operator new must exist which takes one argument of type size_t. For example: void *operator new(size_t __size,void *__arena =NULL) might allocate space in a specified arena (if specified, like Arena=get_arena_address_from_someone_in_charge(); Thing *ptr=new (Arena) Thing; ), or in global memory with no arena specified. The delete operator takes one argument (a void *), or optionally a second argument of type size_t giving the size of the object being deleted. See ARM for more complete info. >--Lyndon VanWagner >-- >----------------------------------------------------------------------------- >Lyndon C. VanWagner Internet:lvw@rama.sc.harris.com >Software Engineer -or- rama!lvw@uu.psi.com >Framework Development Group UUCP: ...!{uupsi,tropix}!rama!lvw >Harris Corporation PHONE: (716) 924-9303 ext. 226 >Scientific Calculations Division, Fishers, NY 14453 >----------------------------------------------------------------------------- >Cornfield's Law (paraphrased): > Before anything can change, everyone must agree. > By the time that happens its a different problem. >----------------------------------------------------------------------------- -- Tory S. Toupin | ttoupin@diana.cair.du.edu | Existence toward perfection... Unversity of Denver | Life of mediocrity! Undergraduate: Math & Computer Sciences| Denver, CO 80208 | - M. E. ----- Ceci n'est pas une signature.