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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!mcsun!sunic!dkuug!daimi!sabroe
  3. From: sabroe@daimi.aau.dk (Morten Sabroe Mortensen)
  4. Subject: Operator "new" - how to catch array-allocation?
  5. Message-ID: <1992Dec14.143339.26314@daimi.aau.dk>
  6. Sender: news@daimi.aau.dk
  7. Organization: DAIMI: Computer Science Department, Aarhus University, Denmark
  8. Date: Mon, 14 Dec 92 14:33:39 GMT
  9. Lines: 39
  10.  
  11.  
  12. As you know, it's possible to attach a special 'new' operator on a
  13. specific class, -something like
  14.  
  15. ...
  16.  
  17. class A
  18. {
  19.   ...
  20.  
  21. public:
  22.   void* operator new(size_t s);
  23. }
  24.  
  25. ...
  26.  
  27. So, well, -when doing something like
  28.  
  29. A* a=new A;
  30.  
  31. the new 'new' for my class A is used, but when doing something like
  32.  
  33. A* a=new A[25];
  34.  
  35. the global new operator is used, it seems! Can it be true, it should
  36. work like this? Until I tried, I thought, A's 'new' would just get a bigger
  37. argument - but maybe there is a very good reason, it works like this?
  38. Please tell me about it! No way to catch array-allocation for a class? 
  39. Same question goes for 'delete'. Comments and explanations greatly
  40. appreciated!
  41.  
  42.  
  43.         -- Morten.
  44.  
  45. ---------------------------------------------------------------------------
  46.  Morten Sabroe Mortensen,         e-mail: sabroe@daimi.aau.dk
  47.  Department of Computer-science - University of Aarhus, Denmark.
  48. ---------------------------------------------------------------------------
  49.  
  50.