Mail Archives: djgpp/2000/09/13/04:18:34
>From: Egon Eckert <egon AT chance DOT cz>
>Reply-To: djgpp AT delorie DOT com
>To: djgpp AT delorie DOT com
>Subject: Re: strdup() with delete[]
>Date: Tue, 12 Sep 2000 11:12:52 +0200
>
> > delete [] obj_ptr is not obsolete. It is _the_proper_ way to deallocate
> > an array of objects. What is obsolete is delete [nn] obj_ptr, where
> > NN would be the number of objects that were allocated for the array.
>
>So, is the delete [] form a hint for the compiler "use vector delete, there
>may be more objects", and the 'simple' delete (without []) is faster
>(because it doesn't need to find out how many objects there are)?
Sort of. If the object array is released using delete [], this would
tell the compiler to generate code that will: 1) call the destructor for
this class for _every_ object in the array; 2) release the memory that
was allocated for _every_ object in the array.
>This is the only reason I would accept the existance of these 2 forms. :)
If you need more info on this, I suggest reading a book on C++. The one
by Bjarne Stroustrup (the creator of C++) is a good one.
----------------
_nimrod_a_abing_
+----------------------------------------------------+
|Homepage: http://www.geocities.com/n_abing/index.htm|
+----------------------------------------------------+
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
- Raw text -