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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!darwin.sura.net!jvnc.net!yale.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!Urmel.Informatik.RWTH-Aachen.DE!messua!dak
  3. From: dak@messua.informatik.rwth-aachen.de (David Kastrup)
  4. Subject: Re: How to keep a member from being deleted thru a pointer?
  5. Message-ID: <dak.722022667@messua>
  6. Sender: news@Urmel.Informatik.RWTH-Aachen.DE (Newsfiles Owner)
  7. Nntp-Posting-Host: messua
  8. Organization: Rechnerbetrieb Informatik  /  RWTH Aachen
  9. References: <1992Nov15.035153.18866@u.washington.edu> <1e567gINNi16@early-bird.think.com>
  10. Date: 17 Nov 92 17:51:07 GMT
  11. Lines: 17
  12.  
  13. barmar@think.com (Barry Margolin) writes:
  14.  
  15. >In article <1992Nov15.035153.18866@u.washington.edu> chuan@stein.u.washington.edu (Chuan Lee) writes:
  16. >>Now if someone does a
  17. >>    delete c.getItem("a member");
  18. >>instead of using
  19. >>    c.removeItem("a member");
  20. >>  So how can I prevent that from happening?
  21.  
  22. >Make Item's destructor private.  Then only members and friends of Item can
  23. >delete instances of Item.
  24.  
  25. >Note, however, that this will also prevent non-members/friends from
  26. >declaring automatic Item variables, since they would have to invoke the
  27. >destructor when the variable's scope ends.
  28.  
  29. Why don't you make the object's delete operator private?
  30.