home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / cplus / 18734 < prev    next >
Encoding:
Text File  |  1993-01-06  |  1.9 KB  |  39 lines

  1. Newsgroups: comp.lang.c++
  2. 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
  3. From: suresh@papaya.iss.nus.sg (Suresh Thennarangam - Research Scholar)
  4. Subject: Re: How to prevent local instances, but allow "new"
  5. Message-ID: <1993Jan6.020119.10396@nuscc.nus.sg>
  6. Sender: usenet@nuscc.nus.sg
  7. Reply-To: suresh@iss.nus.sg (Suresh Thennarangam - Research Scholar)
  8. Organization: Institute Of Systems Science, NUS
  9. References: <1icij0INNdhc@news.cerf.net>
  10. Date: Wed, 6 Jan 1993 02:01:19 GMT
  11. Lines: 26
  12.  
  13. In article <1icij0INNdhc@news.cerf.net> hlf@nic.cerf.net (Howard Ferguson) writes:
  14. >I wish to define a class in a library which the library user
  15. >can create by dynamic allocation via the new operator, but
  16. >I want to prevent him from creating automic instances.
  17. >
  18. >I thought that giving the class a public new operator,
  19. >but a private constructor would work, but this prevents
  20. >any instances of either type from being created.
  21.  
  22. This was covered in this newsgroup a week or so ago.
  23. Make the destructor private... that will do the trick. Declarations
  24. of automatic instances will cause a compilation error when the
  25. scope of the declaration ends.
  26.  
  27.  
  28.       __                  
  29.      (_   / /  o_   o  o |_
  30.      __)/(_( __) (_(_ /_)| )_
  31. ***************************************************************************
  32. * Suresh Thennarangam               *  EMail: suresh@iss.nus.sg(Internet) *
  33. * Research Scholar                  *         ISSST@NUSVM.BITNET          *
  34. * Institute Of Systems Science      *  Tel:  (065) 772 2588.              *
  35. * National University Of Singapore  *  Facs.: (065) 778 2571              *
  36. * Heng Mui Keng Terrace             *  Telex: ISSNUS RS 39988             *
  37. * Singapore 0511.                   *                                     *
  38. ***************************************************************************
  39.