home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16682 < prev    next >
Encoding:
Text File  |  1992-11-20  |  1.3 KB  |  33 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!ux1.cso.uiuc.edu!cs.uiuc.edu!sparc0b!pjl
  3. From: pjl@cs.uiuc.edu (Paul Lucas)
  4. Subject: Re: Self Deletion
  5. Message-ID: <By1Hwt.22p@cs.uiuc.edu>
  6. Sender: news@cs.uiuc.edu
  7. Organization: University of Illinois at Urbana-Champaign
  8. References: <1992Nov20.221751.2482@crd.ge.com>
  9. Distribution: usa
  10. Date: Sat, 21 Nov 1992 00:12:29 GMT
  11. Lines: 20
  12.  
  13. In <1992Nov20.221751.2482@crd.ge.com> jim@galifrey (Jim Weirich) writes:
  14.  
  15. >I am writing a windowed application using C++.  Each window is a C++
  16. >object and interprets button presses and such through member
  17. >functions.  When the CLOSE button is pushed, I wish to delete the
  18. >window. The most straight forward way is have the window object delete
  19. >itself by saying "delete this;" inside the member function handling
  20. >the CLOSE button. This seems to work, but I wonder if it is proper to
  21. >delete an object while executing one of its member functions.
  22.  
  23. >Work arounds obviously are possible (e.g. mark the object for
  24. >deletion, then have another object actually do the "delete" sometime
  25. >later), but why complicate things if self deletion is "OK".
  26.  
  27. *****>    Self-deletion is (will-be) a no-no; static members are another
  28.     work-around.
  29. -- 
  30.     - Paul J. Lucas                University of Illinois    
  31.       AT&T Bell Laboratories        at Urbana-Champaign
  32.       Naperville, IL            pjl@cs.uiuc.edu
  33.