home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 20068 < prev    next >
Encoding:
Text File  |  1993-01-28  |  1.3 KB  |  32 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!agate!dog.ee.lbl.gov!news!vela!cs.uiuc.edu!sparc0b!pjl
  3. From: pjl@cs.uiuc.edu (Paul Lucas)
  4. Subject: Re: Equivalent of realloc().
  5. Message-ID: <C1Irw4.Is3@cs.uiuc.edu>
  6. Sender: news@cs.uiuc.edu
  7. Organization: University of Illinois at Urbana-Champaign
  8. References: <CICCI.93Jan26135919@hpcnnn.cern.ch>
  9. Date: Wed, 27 Jan 1993 15:48:03 GMT
  10. Lines: 20
  11.  
  12. In <CICCI.93Jan26135919@hpcnnn.cern.ch> cicci@hpcnnn.cern.ch (Claudio Condini) writes:
  13.  
  14. >I am implementing a class (in fact, a template) Vector which contains a member
  15. >function resize(int).  This should really be implemented with a realloc(). 
  16. >Any constructor for the Element class of Vector should be called for all and
  17. >only the new elements.  That is, if I have a vector with 20 elements of class
  18. >X and resize it to 30, then the X::X() constructor should be called only for
  19. >the 10 extra elements, and the original 20 elements should not be touched.  Is
  20. >there a way to do this?  I have tried playing with operator new(size_t, void*)
  21. >but did not get very far. 
  22.  
  23.     There's no equivalent to realloc().
  24.  
  25.     See: Tom Cargill, "A Dynamic Vector Is Harder Than It Looks,"
  26.         C++ Report.  It was one of the issues during summer '92
  27.         (I can't remember which).
  28. -- 
  29.     - Paul J. Lucas
  30.       AT&T Bell Laboratories
  31.       Naperville, IL
  32.