home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!plains!plains.NoDak.edu!heilig
- From: heilig@plains.NoDak.edu (Zachary Heilig)
- Newsgroups: comp.lang.c++
- Subject: delete this???
- Message-ID: <20146@plains.NoDak.edu>
- Date: 4 Sep 92 02:29:27 GMT
- Article-I.D.: plains.20146
- Sender: Unknown@plains.NoDak.edu
- Organization: North Dakota Higher Education Computing Network
- Lines: 41
- Nntp-Posting-Host: plains.nodak.edu
-
-
- I saw the previous thread about calling the destructor in member functions,
- and was wondering how legal the following code would be:
-
- --foo.c--
- class foo {
- int *bar;
- public:
- foo();
- ~foo();
- void remove( int = 1 );
- }
-
- foo::foo()
- {
- bar = new int[100];
- }
-
- foo::~foo()
- {
- remove( 0 );
- }
-
- void foo::remove( int call_destruct )
- {
- if( bar ) delete bar;
- if( call_destruct ) delete this;
- }
- --end--
-
- or, should I just call the destructor function?
-
- any ideas?
-
- --
- - Zach Heilig (heilig@plains.nodak.edu)
-
- Ninety-Ninety Rule of Project Schedules:
- The first ninety percent of the task takes ninety percent of
- the time, and the last ten percent takes the other ninety
- percent.
-