home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!usc!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!jvnc.net!newserver.jvnc.net!newsserver.technet.sg!nuscc!papaya!suresh
- From: suresh@papaya.iss.nus.sg (Suresh Thennarangam - Research Scholar)
- Subject: Re: How to prevent local instances, but allow "new"
- Message-ID: <1993Jan6.020119.10396@nuscc.nus.sg>
- Sender: usenet@nuscc.nus.sg
- Reply-To: suresh@iss.nus.sg (Suresh Thennarangam - Research Scholar)
- Organization: Institute Of Systems Science, NUS
- References: <1icij0INNdhc@news.cerf.net>
- Date: Wed, 6 Jan 1993 02:01:19 GMT
- Lines: 26
-
- In article <1icij0INNdhc@news.cerf.net> hlf@nic.cerf.net (Howard Ferguson) writes:
- >I wish to define a class in a library which the library user
- >can create by dynamic allocation via the new operator, but
- >I want to prevent him from creating automic instances.
- >
- >I thought that giving the class a public new operator,
- >but a private constructor would work, but this prevents
- >any instances of either type from being created.
-
- This was covered in this newsgroup a week or so ago.
- Make the destructor private... that will do the trick. Declarations
- of automatic instances will cause a compilation error when the
- scope of the declaration ends.
-
-
- __
- (_ / / o_ o o |_
- __)/(_( __) (_(_ /_)| )_
- ***************************************************************************
- * Suresh Thennarangam * EMail: suresh@iss.nus.sg(Internet) *
- * Research Scholar * ISSST@NUSVM.BITNET *
- * Institute Of Systems Science * Tel: (065) 772 2588. *
- * National University Of Singapore * Facs.: (065) 778 2571 *
- * Heng Mui Keng Terrace * Telex: ISSNUS RS 39988 *
- * Singapore 0511. * *
- ***************************************************************************
-