This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: operator new[] and operator delete[]
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
>