Releasing Dynamic Memory with delete
To destroy a dynamically allocated object and free the space for the object, use the
delete operator as follows:
This statement first calls the destructor for the object to which timePtr points, then deallocates the memory associated with the object, returning the memory to the free store.
Common Programming Error 10.2
Not releasing dynamically allocated memory when it’s no longer needed can cause the system to run out of memory prematurely. This is sometimes called a “memory leak.”