Path: utzoo!attcan!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c++ Subject: Re: Objective suicide Message-ID: <282@taumet.com> Date: 30 Jun 90 21:42:15 GMT References: <685@dyndata.UUCP> <276@taumet.com> <9299@cadillac.CAD.MCC.COM> Reply-To: steve@taumet.UUCP (Stephen Clamage) Organization: Taumetric Corporation, San Diego Lines: 25 In article <9299@cadillac.CAD.MCC.COM> vaughan@mcc.com (Paul Vaughan) writes: > From: steve@taumet.com (Stephen Clamage) > In article <685@dyndata.UUCP> dan@dyndata.UUCP (Dan Everhart) writes: > >Is it kosher for an object to delete itself? To wit: > >class Obj > > { > > void Suicide () { /* ... */ delete this; } > > } > Yes, but do be careful, as noted in your full example. I have done this > in a class destructor, but would not do it in a normal member function. > [... ] >I'm having trouble making sense out of this. [...] If you have a color monitor, insert my red face here. Michael Tiemann was also kind enough to point out that what I said could not possibly have been what I meant. Please disregard my previous posting, and in future I'll try not to respond to net news before my morning coffee. You can "delete this;" in a member function, but as in my earlier posting, you must be very careful to avoid a second deletion by a call to the destructor, and also avoid any later reference to any virtual functions (including virtual destructors). In other words, it's dangerous. -- Steve Clamage, TauMetric Corp, steve@taumet.com