robert@ireq.hydro.qc.ca (R.Meunier 8516) (06/19/91)
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);
}
this is the c code after cfront
----------------------------------------------------------------------
/* <<AT&T C++ Translator 2.00.02 08/25/89>> */
/* < int.cc > */
char *__vec_new ();
char __vec_delete ();
typedef int (*__vptp)();
struct __mptr {short d; short i; __vptp f; };
extern char *__nw__FUi ();
int main (){ _main();
{
int *__1i ;
{
int *__0__N1 ;
__1i = ( ( (__0__N1 = (((int *)__nw__FUi ( sizeof (int )) ))), (((*__0__N1 ))= 10 )) , __0__N1 );
}
}
}
----------------------------------------------------------------------
Do i have to create an Int class?
PS i couldn't find anything int the ARM!
--
Robert Meunier Institut de Recherche d'Hydro-Quebec
Ingenieur 1800 Montee Ste-Julie, Varennes
Internet: robert@ireq.hydro.qc.ca Qc, Canada, J3X 1S1
maintainer: BASIC mailing list request to basic-request@ireq.hydro.qc.cahitz@csi.uottawa.ca (Martin Hitz) (06/19/91)
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