home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!think.com!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!meibm31.cen.uiuc.edu!pl2440
- From: pl2440@meibm31.cen.uiuc.edu (Paul Jay Lucas)
- Subject: Re: How to run destructors of all objects when failure exit occurs ?
- References: <AAAsb0h8xN@inpbox.inp.nsk.su>
- Message-ID: <BxsFJE.6GL@news.cso.uiuc.edu>
- Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
- Organization: University of Illinois at Urbana
- Date: Mon, 16 Nov 1992 02:42:50 GMT
- Lines: 22
-
- In <AAAsb0h8xN@inpbox.inp.nsk.su> dolgov@inpbox.inp.nsk.su (Yuri V. Dolgov) writes:
-
- > Often I use failure program exit when some conditions are bad.
- >The trouble is: I created some objects (e.g. dialog boxes, network connections
- >and so on) and I want to run destructors before program exit.
- >Is there exist standard technique in C++ language to solve this problem ?
-
- No; only statically-allocated objects are destroyed. Off the
- top of my head, *a* way to have auto-objects destroyed would be
- to make them register themselves with some global list of
- objects on construction and deregister themselves on
- destruction. Now, when the global "clean-up" object gets
- destroyed, it could destroy all objects that are still
- registered.
-
- Actually, they can't be auto objects, but must instead be
- dynamically-allocated objects; it is illegal to delete anything
- not allocated by new (as auto objects aren't).
- --
- - Paul J. Lucas University of Illinois
- AT&T Bell Laboratories at Urbana-Champaign
- Naperville, IL pjl@cs.uiuc.edu
-