Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!spool.mu.edu!uunet!lotus!lotus.com!robertk From: robertk@lotatg.lotus.com (Robert Krajewski) Newsgroups: comp.lang.c++ Subject: Re: How to get the functionality of realloc() in C++ ? Message-ID: Date: 20 May 91 22:54:10 GMT Article-I.D.: lotatg.ROBERTK.91May20175410 References: <1991May13.191807.29295@csl.dl.nec.com> <728@taumet.com> Sender: news@lotus.com Organization: Lotus Development Corporation Lines: 14 In-Reply-To: steve@taumet.com's message of 14 May 91 22:01:25 GMT If you are really looking for the functionality of arrays that can be resized, you might as well use realloc() directly, and place the implementation inside an array class. If you are using the array as container (with one class of C++ objects directly residing in the storage managed by the array), you will need to use the placement form of the operator so that your constructors are run properly (in a loop, most likely). If you shrink the array, you will need to manually run the destructors for the deleted objects. Container classes are pretty useful, especially when you want to tune the storage of a particular family or set of objects. For example, you could write an array class that used handle-based storage on the Mac or Windows, and thus be better-behaved than a simple port that assumed optimal implementations of malloc/realloc/free.