operator new[] and operator delete[]

Wesley Smith wesley.hoke@gmail.com
Mon Jul 30 21:37:00 GMT 2007


oh yeah!! rusty C++.  thanks.
wes

On 7/30/07, Young, Michael <Michael.Young@paetec.com> wrote:
> > I've noticed if I do:
> >
> > Object *o = new Object[100];
> >
> > It calls new[] but if I do
> >
> > delete o;
> >
> > later it calls delete and therefore isn't symmetrical.  How can I get
> > delete[] called?
>
> You need to call the array delete using the following syntax :
>
> delete [] o;
>
> If you simply "delete o;", as in your example, you are only deleting the
> first object in the array (and leaving 99 "orphaned" objects in memory).
>
>   - Mike
>



More information about the Gcc-help mailing list