August 2012
Intermediate to advanced
976 pages
30h 17m
English
In C++, dynamic memory is managed through a pair of operators: new
, which allocates, and optionally initializes, an object in dynamic memory and returns a pointer to that object; and delete
, which takes a pointer to a dynamic object, destroys that object, and frees the associated memory.
Dynamic memory is problematic because it is surprisingly hard to ensure that we free memory at the right time. Either we forget to free the memory—in which case we have a memory leak—or we free the memory when there are still pointers referring to that memory—in which case we have a pointer that refers to memory that is no longer valid.
To make using dynamic memory easier (and safer), the new library provides two ...
Read now
Unlock full access