Skip to content

Latest commit

 

History

History
105 lines (64 loc) · 1.76 KB

CppDelete.md

File metadata and controls

105 lines (64 loc) · 1.76 KB

 

 

 

 

 

 

delete is a keyword to release dynamically allocated memory (allocated by the keyword new).

 

 

 

 

 

Examples

 

 

 

 

 

 

 

 

Be aware that it is valid to delete a pointer-to-const.

 

 

 

 

 

 

  1. Herb Sutter and Andrei Alexandrescu. C++ coding standards: 101 rules, guidelines, and best practices. ISBN: 0-32-111358-6. Chapter 13: 'Ensure resources are owned by objects. Use explicit RAII and smart pointers.'
  2. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Page 19, 1.3.2 'Advice', item 3: 'Avoid 'naked' new and delete'
  3. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 11.6. Advice. page 303: '[4] Avoid "naked new" and "naked delete"'
  4. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 21.4. Advice. page 640: '[1] Use unique_ptr or shared_ptr to avoid forgetting to delete objects created using new'