lvw@rama.UUCP (Lyndon VanWagner) (06/07/91)
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? Thanks for the information. --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. -----------------------------------------------------------------------------
ttoupin@diana.cair.du.edu (Aerin) (06/11/91)
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.