🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#7543
From: Pang Fu
Date: Wed, 09 Jul 2003 14:08
44 lines
2013 bytes
Is it possible for an instance of a class to delete itself upon receive a
message as shown below?

Say:

class TMyClass
{
public :
   TMyClass();
   ~TMyClass();
   void Command(int C);
};

...

void TMyClass::Command(int C)
{
   if (C > 0)
      for (int i=0; i<C; i++){
          Beep();
          Sleep(1000);
      }
  else if (C==0) {
     Destruct TMyClass instance .. HOW?
  }

}

...

TMyClass *MyObject;

MyObject = new TMyClass();

MyObject->Command(10); // Beep 10 times
MyObject->Command(5);  // Beep 5 times
MyObject->Command(0); // Delete MyObject HOW?

I want to send command to object to delete itself instead of using "delete
MyObject". Is it possible ?


Pang Fu
nospam_pangfu@hotmail.com
Technical Details
Message-ID: <3f0c21da@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!rip!news.webusenet.com!peer01.cox.net!cox.net!in.100proofnews.com!in.100proofnews.com!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,9af595df0adad9f3,start
X-Google-Attributes: gid10cc67,public
X-Google-Thread: 10db1e,9af595df0adad9f3,start
X-Google-Attributes: gid10db1e,public
X-Google-Thread: 102541,9af595df0adad9f3,start
X-Google-Attributes: gid102541,public
X-Google-ArrivalTime: 2003-07-09 07:10:42 PST
From: "Pang Fu" <nospam_pangfu@hotmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi,borland.public.cppbuilder.oodesign,borland.public.cppbuilder.students
Subject: Self destructive 0bject/class... (Challange)
Date: Thu, 10 Jul 2003 00:08:24 +1000
Lines: 50
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 210.50.97.32
Message-ID: <3f0c21da@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1057759706 210.50.97.32 (9 Jul 2003 07:08:26 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!rip!news.webusenet.com!peer01.cox.net!cox.net!in.100proofnews.com!in.100proofnews.com!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail