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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!microsoft!hexnut!jimad
  3. From: jimad@microsoft.com (Jim Adcock)
  4. Subject: Re: Operator "new" - how to catch array-allocation?
  5. Message-ID: <1992Dec15.192946.25542@microsoft.com>
  6. Date: 15 Dec 92 19:29:46 GMT
  7. Organization: Microsoft Corporation
  8. References: <1992Dec14.143339.26314@daimi.aau.dk>
  9. Lines: 26
  10.  
  11. In article <1992Dec14.143339.26314@daimi.aau.dk> sabroe@daimi.aau.dk (Morten Sabroe Mortensen) writes:
  12. |A* a=new A[25];
  13. |
  14. |the global new operator is used, it seems! Can it be true, it should
  15. |work like this? 
  16.  
  17. It should work like this?  It does work like this.
  18.  
  19. |Until I tried, I thought, A's 'new' would just get a bigger
  20. |argument - but maybe there is a very good reason, it works like this?
  21.  
  22. Maybe.  The argument being that class operator new should be allowed to
  23. handled fixed-size allocations.
  24.  
  25. |Please tell me about it! No way to catch array-allocation for a class? 
  26.  
  27. Way.  Catch array-allocation for a class by preventing array allocations.
  28. For example make constructors private.  Or no default constructors.
  29.  
  30. |Same question goes for 'delete'. Comments and explanations greatly
  31. |appreciated!
  32.  
  33. If you want to perform custom new and delete on arrays of objects make
  34. that array a class.  If you want the capabilities of classes, then
  35. make it a class.  The built-in array capabilities of C++ are a left-over
  36. from C days, and are not to be taken seriously.
  37.