delete not a function, it is an operator.
A delete expression using [] destroys the objects created with new ... [] and frees the associated memory. delete[] should be used for pointers returned by new ... [] ; non-array delete only for pointers returned by the non-array new . Using an inappropriate delete form is always incorrect.
The delete in ~Table() (missing () in your code) will destroy the dynamically created array of Name objects, ensuring that the Name destructor is called for each member of the array.
An implementation to implement some mechanism for recording the number of elements in arrays allocated using new ... [] , the programmer does not need to worry about this.
In many implementations where the elements of the array have non-trivial destructors, the expression new[] allocates additional space for writing the element counter in front of the space for all members of the array. This hidden count is then checked when delete[] used to ensure the correct number of destructors. This is just an implementation detail, but other implementations are possible.
Charles Bailey
source share