The delete operator deallocates an object created with the new operator. The delete operator has a result of type void and therefore does not return a value. The operand to delete must be a pointer returned by the new operator.
Using delete on a pointer to an object not allocated with new gives unpredictable results. You can, however, use delete on a pointer with the value 0. This provision means that, because new always returns 0 on failure, deleting the result of a failed new operation is harmless.
Syntax
deallocation-expression :
::opt delete cast-expression
::opt delete [ ] cast-expression
Using the delete operator on an object deallocates its memory. A program that dereferences a pointer after the object is deleted can have unpredictable results or crash.
If the operand to the delete operator is a modifiable l-value, its value is undefined after the object is deleted.
Pointers to const objects cannot be deallocated with the delete operator.