home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 18003 < prev    next >
Encoding:
Text File  |  1992-12-15  |  1.3 KB  |  41 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!taumet!steve
  3. From: steve@taumet.com (Steve Clamage)
  4. Subject: Re: Operator "new" - how to catch array-allocation?
  5. Message-ID: <1992Dec15.174103.23400@taumet.com>
  6. Organization: TauMetric Corporation
  7. References: <1992Dec14.143339.26314@daimi.aau.dk>
  8. Date: Tue, 15 Dec 1992 17:41:03 GMT
  9. Lines: 30
  10.  
  11. sabroe@daimi.aau.dk (Morten Sabroe Mortensen) writes:
  12.  
  13. >As you know, it's possible to attach a special 'new' operator on a
  14. >specific class, -something like
  15. >class A
  16. >{
  17. >public:
  18. >  void* operator new(size_t s);
  19. >}
  20.  
  21. >So, well, -when doing something like
  22. >    A* a=new A;
  23. >the new 'new' for my class A is used, but when doing something like
  24. >    A* a=new A[25];
  25. >the global new operator is used, it seems! Can it be true, it should
  26. >work like this?
  27.  
  28. Yes, that is what is specified in the ARM, and current C++ implementations
  29. work that way.  It is explained in the ARM on page 60.
  30.  
  31. At the last C++ Committee meeting (November 1992, Boston) we voted in
  32. a new syntax to allow overriding the 'new' used for allocating
  33. arrays with a class-specific version.  This would be a different
  34. operator new() from the one which allocates a single object.
  35.  
  36. Future implementations of C++ should support this new feature, assuming
  37. it is not later removed or modified.
  38. -- 
  39.  
  40. Steve Clamage, TauMetric Corp, steve@taumet.com
  41.