home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: Operator "new" - how to catch array-allocation?
- Message-ID: <1992Dec15.174103.23400@taumet.com>
- Organization: TauMetric Corporation
- References: <1992Dec14.143339.26314@daimi.aau.dk>
- Date: Tue, 15 Dec 1992 17:41:03 GMT
- Lines: 30
-
- sabroe@daimi.aau.dk (Morten Sabroe Mortensen) writes:
-
- >As you know, it's possible to attach a special 'new' operator on a
- >specific class, -something like
- >class A
- >{
- >public:
- > void* operator new(size_t s);
- >}
-
- >So, well, -when doing something like
- > A* a=new A;
- >the new 'new' for my class A is used, but when doing something like
- > A* a=new A[25];
- >the global new operator is used, it seems! Can it be true, it should
- >work like this?
-
- Yes, that is what is specified in the ARM, and current C++ implementations
- work that way. It is explained in the ARM on page 60.
-
- At the last C++ Committee meeting (November 1992, Boston) we voted in
- a new syntax to allow overriding the 'new' used for allocating
- arrays with a class-specific version. This would be a different
- operator new() from the one which allocates a single object.
-
- Future implementations of C++ should support this new feature, assuming
- it is not later removed or modified.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
-