Click here to Skip to main content
Click here to Skip to main content
Alternative Tip/Trick

Tagged as

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

, 31 Aug 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
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....
A good exercise to aid in always using delete [] where appropriate is to code your own autoarray_ptr<class T> 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. Stroustrup didn't include it in C++ Programming Language since he assumed once you had auto_ptr it was just boiler plate to code your own class for autoarray_ptr.

License

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

Share

About the Author

MilesAhead

United States United States
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.1411019.1 | Last Updated 31 Aug 2010
Article Copyright 2010 by MilesAhead
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid