Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!lll-winken!sun-barr!apple!voder!pyramid!octopus!sjsumcs!horstman From: horstman@mathcs.sjsu.edu (Cay Horstmann) Newsgroups: comp.lang.c++ Subject: Re: c++ storage management of arrays Keywords: c++ Message-ID: <1991Feb10.024945.9137@mathcs.sjsu.edu> Date: 10 Feb 91 02:49:45 GMT References: <21795@rasp.eng.cam.ac.uk> Organization: San Jose State University - Math/CS Dept. Lines: 16 In article <21795@rasp.eng.cam.ac.uk> act@eng.cam.ac.uk (A.C.Thornton) writes: >I have a question about the allocation of arrays of classes. How >do I increase the size of an array of classes after I've already >allocated it using "new." Unfortunately, you cannot easily do that except for the obvious solution of allocating a bigger array and copying over the existing elements. Note that you CANNOT use memcpy to copy the existing elements if the array contains objects with nontrivial copy semantics. For syntactic sugar, you could define an overloaded operator new for this case ( like a = new T[50] , /* ... */ a = new(a) T[100]; ) Note that the new to be changed is the global ::new. Cay