new and delete in C++ — a practical guide to C++ new delete with clear examples you can reuse in real projects.
C++ Tutorial Series (50/111). Prefer one article? Read the complete C++ tutorial.
Short description
Never mix new with free, or new[] with delete.
new/delete
int* p = new int(42);
// ...
delete p;
p = nullptr;