🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #15310

Re: Self destructive 0bject/class... (Challange)

#15310
From: Alan Bellingham
Date: Wed, 09 Jul 2003 14:25
21 lines
1739 bytes
"Pang Fu" <nospam_pangfu@hotmail.com> wrote:

>Is it possible for an instance of a class to delete itself upon receive a
>message as shown below?

Yes: "delete this;"

Note - you must make very sure that the function then returns without
accessing any non-static methods or members.

Also, you must make sure that nothing else is ever going to access the
object again.

Both of these are possible, and this is actually how COM components
usually work - they have functions 'AddRef()' and 'Release()', with the
Release method usually causing object deletion when an internal count
gets down to zero.

Alan Bellingham
-- 
alanb@episys.com
Technical Details
Message-ID: <359ogv4ma0486k3iath6cf42eqvg4ab6u0@4ax.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!priapus.visi.com!news-out.visi.com!green.readfreenews.net!news.readfreenews.net!cox.net!news-xfer.cox.net!in.100proofnews.com!in.100proofnews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3f0c21da@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,9af595df0adad9f3
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-07-09 07:25:19 PST
From: Alan Bellingham <alanb@episys.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Self destructive 0bject/class... (Challange)
Date: Wed, 09 Jul 2003 15:25:04 +0100
Reply-To: alanb@episys.com
Message-ID: <359ogv4ma0486k3iath6cf42eqvg4ab6u0@4ax.com>
References: <3f0c21da@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.92/32.572
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 193.129.251.7
X-Trace: newsgroups.borland.com 1057760654 193.129.251.7 (9 Jul 2003 07:24:14 -0700)
Lines: 21
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!priapus.visi.com!news-out.visi.com!green.readfreenews.net!news.readfreenews.net!cox.net!news-xfer.cox.net!in.100proofnews.com!in.100proofnews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail