Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!uw-june!uw-entropy!dataio!bright From: bright@Data-IO.COM (Walter Bright) Newsgroups: comp.lang.c++ Subject: Re: initializing array of objects Message-ID: <2016@dataio.Data-IO.COM> Date: 19 Jun 89 18:54:27 GMT References: <1284@cadillac.CAD.MCC.COM> Reply-To: bright@dataio.Data-IO.COM (Walter Bright) Organization: Data I/O Corporation; Redmond, WA Lines: 12 In article <1284@cadillac.CAD.MCC.COM> rpj@redcloud.cad.mcc.com (Rich Johns) writes: >class Foo; >Foo** fooArray; >fooArray = new Foo*[100]; >for (int i = 0; i < 100; i++) fooArray[i] = 0; >Is there a better way to initialize fooArray? Try: memset(fooArray,0,100 * sizeof(fooArray[0])); or: fooArray = (Foo**) calloc(100,sizeof(fooArray[0])); Both are faster and generate less code.