home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- 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
- From: dak@messua.informatik.rwth-aachen.de (David Kastrup)
- Subject: Re: How to keep a member from being deleted thru a pointer?
- Message-ID: <dak.722022667@messua>
- Sender: news@Urmel.Informatik.RWTH-Aachen.DE (Newsfiles Owner)
- Nntp-Posting-Host: messua
- Organization: Rechnerbetrieb Informatik / RWTH Aachen
- References: <1992Nov15.035153.18866@u.washington.edu> <1e567gINNi16@early-bird.think.com>
- Date: 17 Nov 92 17:51:07 GMT
- Lines: 17
-
- barmar@think.com (Barry Margolin) writes:
-
- >In article <1992Nov15.035153.18866@u.washington.edu> chuan@stein.u.washington.edu (Chuan Lee) writes:
- >>Now if someone does a
- >> delete c.getItem("a member");
- >>instead of using
- >> c.removeItem("a member");
- >> So how can I prevent that from happening?
-
- >Make Item's destructor private. Then only members and friends of Item can
- >delete instances of Item.
-
- >Note, however, that this will also prevent non-members/friends from
- >declaring automatic Item variables, since they would have to invoke the
- >destructor when the variable's scope ends.
-
- Why don't you make the object's delete operator private?
-