Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!bu-cs!mirror!necntc!necis!mrst!sdti!wmm From: wmm@sdti.com (William M. Miller) Newsgroups: comp.lang.c++ Subject: Re: multiple destructors Message-ID: <1989Oct19.022635.123@sdti.com> Date: 19 Oct 89 02:26:35 GMT References: <1989Sep30.190719.3340@polyslo.CalPoly.EDU> <6590273@hplsla.HP.COM> Reply-To: wmm@sdti.SDTI.COM (William M. Miller) Organization: Software Development Technologies, Inc. Lines: 20 In article <6590273@hplsla.HP.COM> jima@hplsla.HP.COM (Jim Adcock) writes: >//the following [weak] example either uses built-in new or malloc for space. >//it uses a dirty trick of initializing a field of foo in new. is there a >//better way? It is a dirty trick; worse, it's not a general solution. I wanted some way of determining whether or not a given object was automatic, static, or heap-based; my thought was to use operator new() in the way you did, setting a flag to reveal the history of the object, but the problem is that operator new() is not called for auto and static objects and the garbage in auto objects could very well impersonate the flag left by operator new() in a heap-based object. I, too, join in a call for a better way of doing this sort of thing. At least in the old hack of assigning to "this" you could tell whether the object was going into the heap or whether storage had already been allocated for it. -- Non-disclaimer: My boss and I always see eye-to-eye (every time I look in the mirror). ...!genrad!mrst!sdti!wmm