Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!milano!cadillac!redcloud!rpj From: rpj@redcloud.cad.mcc.com (Rich Johns) Newsgroups: comp.lang.c++ Subject: deallocating an array of objects Message-ID: <1245@cadillac.CAD.MCC.COM> Date: 15 Jun 89 21:18:47 GMT Sender: news@cadillac.CAD.MCC.COM Lines: 45 Assume: class Foo { Foo() { /*stuff*/} ~Foo() { /* stuff*/} //stuff }; main() { Foo** fooArray = nil; fooArray = new Foo*[100]; // do something } My question has to do with deallocating fooArray. If I am not concerned with deleting the contents of fooArray (the 100 Foos), it seems like: delete fooArray; is correct. If I did want to delete the 100 Foos, would this be correct: delete [100]fooArray; or would I have to: for (int i = 0; i < 100; i++) { delete fooArray[i]; } delete fooArray; Would the answer be different if Foo does not have a constructor and destructor? thanks. Rich Johns, MCC CAD Program | 3500 W. Balcones Center Dr., Austin, TX 78759 ARPA: johns@mcc.com | Phone: [512] 338-3714 UUCP: {uunet,harvard,gatech,pyramid}!cs.utexas.edu!milano!cadillac!johns