Click here to Skip to main content
12,999,744 members (40,496 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked
Posted 1 Oct 2010

C++ Tip: Aware of the confusion between delete with delete[]

, 1 Oct 2010
The C++ comes with a rich standard library: the STL (Standard Template Library).So, why we should re-invent the wheel while we already have it done, safe and written to be light-weighed and performant?It's too much better to use the vector Class (Standard C++ Library)[^]:#include...


Members may post updates or alternatives to this current article in order to show different approaches or add new features.

31 Aug 2010
A good exercise to aid in always using delete [] where appropriate is to code your own autoarray_ptr following the pattern of c++ auto_ptr. The destructor calls delete [] when the instance goes out of scope. Saves writing a lot of messy delete [] code in "if chains" and switch blocks....
13 Aug 2011
It is a bad idea to treat built-in types differently than programmer defined classes. If you delete a dynamically allocated array of a built-in type without the brackets the memory buffer may go away just fine. This is not guaranteed. The VS2008 runtime throws an exception. There is a...
31 Aug 2010
3 alternatives  


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Sauro Viti
Engineer Cutlite Penta S.r.l.
Italy Italy
No Biography provided

| | Privacy | Terms of Use | Mobile
Web02 | 2.8.170624.1 | Last Updated 1 Oct 2010
Article Copyright 2010 by Sauro Viti
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid