The core idea is: objects allocated with new
must be deallocated with
delete
. These are said to have "dynamic storage duration."
Global variables have "static storage duration" and exist for the lifetime of the program.
Other variables (mainly function local variables, object members) have "automatic storage duration." These are destroyed, and their space reclaimed, when they go out of scope, and only then.