home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!olivea!pagesat!spssig.spss.com!uchinews!msuinfo!pacific.cps.msu.edu!baldwin
- From: baldwin@cps.msu.edu (Reid A Baldwin)
- Newsgroups: comp.lang.c++
- Subject: eliminating automatic calls to member destructors
- Message-ID: <1i9qlgINNdnp@msuinfo.cl.msu.edu>
- Date: 4 Jan 93 17:03:44 GMT
- Sender: baldwin@pacific.cps.msu.edu (Reid A Baldwin)
- Organization: Dept. of Computer Science, Michigan State University
- Lines: 25
- NNTP-Posting-Host: pacific.cps.msu.edu
-
- I am implementing a program that uses persistent objects. Some of the
- the classes I use have an integer delete_status member. When delete_status
- is 0, the object should not be deleted. My intention was to implement
- this feature by redefining the delete operator so that is checks the
- delete_status before calling the regular delete operator, and doesn't call
- it if delete_status is 0. That works fine. However, the destructors are
- automatically being called for each of the data members of the class.
- Some of these data members call delete for parts of their data structures.
- So, some of the data structure gets deleted anyway.
-
- I could find an in-elegant solution by associating another delete_status
- member with each of the data members that call delete. Setting them all
- correctly seems quite error prone. Also, if someone derives classes from
- my classes and they add data members with destructors that call delete,
- they would have to know about maintaining a delete_status. This solution
- doesn't satisfy me.
-
- Instead, I would like to avoid the calls to the member destructors in
- the first place. I don't know how to communicate this to the compiler so
- it doesn't insert them automatically after each return. Is there some kind
- of super-return statement that doesn't automatically destroy the members?
-
- Thanks for any help,
- Reid Baldwin
- baldwin@cps.msu.edu
-