RE: [AD] [OT] new operator

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


> Interesting. If they define it as
> 
> 	 void * operator new (size_t sz)
> 
> then how come constructions like 
> 
> 	 float *f = new float[10];
> 
> work? I would think it would cause a compiler error saying that a cast
> is required from void * to float *. Am I missing something here?

They are two different things, I think.
void * operator new (size_t sz)
is the global new operator used to allocate memory, and
float *f = new float[10];
uses the new keyword, which calls the new operator to allocate the
memory, then calls whatever ctors are needed.

-- 
Vincent Penquerc'h 




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/