On this page
  1. new & delete
  2. Overview
  3. When Raw new Still Appears
  4. Pitfalls

new & delete

Prev: sizeof & alignof | Up: builtins | Next: C++ Named Casts
Rel: std::unique_ptr, std::make_unique, RAII, Smart Pointers & Lifetime
Ref: cppreference — new expression
Tags: #public #prog #cpp #builtins #memory #tier/specialized


Overview

new allocates dynamic memory and constructs an object; delete runs the destructor and frees the memory (new[] / delete[] for arrays). In modern C++, avoid raw owning new and delete in application code—prefer std::make_unique, std::make_shared, or standard containers like std::vector.

When Raw new Still Appears

Pitfalls

Linked from

Related notes