Newsgroups: comp.lang.c++ Path: utzoo!utgpu!cunews!csi.uottawa.ca!news From: hitz@csi.uottawa.ca (Martin Hitz) Subject: Re: new for array of int Message-ID: <1991Jun19.160009.18119@csi.uottawa.ca> Sender: news@csi.uottawa.ca Nntp-Posting-Host: sim5 Organization: University of Ottawa References: <7525@s3.ireq.hydro.qc.ca> Distribution: na Date: Wed, 19 Jun 91 16:00:09 GMT In article <7525@s3.ireq.hydro.qc.ca> robert@ireq.hydro.qc.ca () writes: > I'm looking for a way to allocate an array of integer (or >any other type) using the operator new. I thought that the >following line would have create an array of 10 element >but found out looking at the c code generated that 10 was >assigned to the int. > >maint() >{ > int *i; > > i = new int(10); >} While the correct form to allocate an array would be i = new int[10]; the one used here initializes a newly allocated singleton with the argument to the pseudo-constructor-call. Martin Hitz@csi.uottawa.ca