On 2011-02-04 14:30-0800 Alan W. Irwin wrote:

> Anyone care to have a go at explaining the difference in meaning between
>
> delete text[k];
>
> and
>
> delete [] text[k];
>
> ?
>
> Both compile, run, and produce good results; but the former annoys
> valgrind (and may actually do bad things) while the latter does not.

To answer my own question (in part) from
http://www.cplusplus.com/doc/tutorial/dynamic/, the first form deletes
memory "allocated for a single element, and the second one for memory
allocated for arrays of elements".

However, I must say I don't understand why C++ implements new for
single quantities and also has a special syntax for deleting those new
single quantities. Is there some advantage to using "new" and delete
for single quanties compared to just using ordinary automatic
variables? I hope someone who understands C++ will enlighten me.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________

------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to