home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / cplus / 18355 < prev    next >
Encoding:
Text File  |  1992-12-23  |  1.4 KB  |  36 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!rational.com!thor!rmartin
  3. From: rmartin@thor.Rational.COM (Bob Martin)
  4. Subject: Re: Undefined new and delete
  5. Message-ID: <rmartin.725129816@thor>
  6. Sender: news@rational.com
  7. Organization: Rational
  8. References: <1992Dec21.162241.12012@cbnewsk.cb.att.com>
  9. Date: Wed, 23 Dec 1992 16:56:56 GMT
  10. Lines: 24
  11.  
  12. swk7@cbnewsk.cb.att.com (steven.w.koenig) writes:
  13.  
  14. |If one wanted to insure that no objects of a given type were ever created
  15. |on the heap, it seems logical that one should be able to declare the
  16. |new and delete operators as private but not define them.
  17.  
  18. Unfortunately, this does not insure that the objects will not be
  19. allocated on the heap.  If an array is allocated, the operator new
  20. member will not be invoked; the global operator new will be invoked
  21. instead, and the objects will be on the heap.
  22.  
  23. If you REALLY want to insure that the objects cannot be allocated on
  24. the heap, then make all the constructors private.  Create a helper
  25. class which is a friend.  The helper class will ALWAYS create the
  26. object on the heap, even though the helper itself may be allocated in
  27. many different ways....
  28.  
  29.  
  30.  
  31. --
  32. Robert Martin                        Training courses offered in:
  33. R. C. M. Consulting                       Object Oriented Analysis
  34. 2080 Cranbrook Rd.                        Object Oriented Design
  35. Green Oaks, Il 60048 (708) 918-1004       C++
  36.