home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / cplus / 18423 < prev    next >
Encoding:
Internet Message Format  |  1992-12-25  |  1.6 KB

  1. Path: sparky!uunet!pipex!bnr.co.uk!uknet!mcsun!fuug!kiae!demos!newsserv
  2. From: mike@istech.msk.su (Michael Korotkih)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Operator "new" - how to catch array-allocation?
  5. Message-ID: <AAtppDh498@istech.msk.su>
  6. Date: 22 Dec 92 16:06:15 GMT
  7. References: <1992Dec14.143339.26314@daimi.aau.dk>
  8. Sender: news-service@newcom.kiae.su
  9. Reply-To: mike@istech.msk.su
  10. Organization: Information Systems and Technologies
  11. Lines: 31
  12.  
  13.  
  14. > A* a=new A[25];
  15.  
  16. > the global new operator is used, it seems! Can it be true, it should
  17. > work like this?
  18.         YES. A::new used only if you allocate exactly one object of
  19.     class A or derived from A ( size == sizeof( classname ) ),
  20.     if you use this for derived class, size will be bigger.
  21.  
  22.  
  23. >        Until I tried, I thought, A's 'new' would just get a bigger
  24. > argument - but maybe there is a very good reason, it works like this?
  25. > Please tell me about it! No way to catch array-allocation for a class?
  26.     You can override global ::operator new. If you want execute
  27.     class - specific initialization, may be constractor - the best place.
  28.  
  29.  
  30. > Same question goes for 'delete'. Comments and explanations greatly
  31. > appreciated!
  32.  
  33.     delete behavior is the same.
  34.  
  35. >        -- Morten.
  36.  
  37. > ---------------------------------------------------------------------------
  38. >  Morten Sabroe Mortensen,         e-mail: sabroe@daimi.aau.dk
  39. >  Department of Computer-science - University of Aarhus, Denmark.
  40. > ---------------------------------------------------------------------------
  41.  
  42.  
  43.                                                   Michael Korotkih
  44.