home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!rational.com!thor!rmartin
- From: rmartin@thor.Rational.COM (Bob Martin)
- Subject: Re: Undefined new and delete
- Message-ID: <rmartin.725129816@thor>
- Sender: news@rational.com
- Organization: Rational
- References: <1992Dec21.162241.12012@cbnewsk.cb.att.com>
- Date: Wed, 23 Dec 1992 16:56:56 GMT
- Lines: 24
-
- swk7@cbnewsk.cb.att.com (steven.w.koenig) writes:
-
- |If one wanted to insure that no objects of a given type were ever created
- |on the heap, it seems logical that one should be able to declare the
- |new and delete operators as private but not define them.
-
- Unfortunately, this does not insure that the objects will not be
- allocated on the heap. If an array is allocated, the operator new
- member will not be invoked; the global operator new will be invoked
- instead, and the objects will be on the heap.
-
- If you REALLY want to insure that the objects cannot be allocated on
- the heap, then make all the constructors private. Create a helper
- class which is a friend. The helper class will ALWAYS create the
- object on the heap, even though the helper itself may be allocated in
- many different ways....
-
-
-
- --
- Robert Martin Training courses offered in:
- R. C. M. Consulting Object Oriented Analysis
- 2080 Cranbrook Rd. Object Oriented Design
- Green Oaks, Il 60048 (708) 918-1004 C++
-