How delete “this” operator works in C++ with example

The delete operator should work only with the objects that are allocated memory using the operator new. The delete is used to de-allocate the memory.
The delete operator should not be used for this pointer.

See the below example, to understand how delete works.

2) See the below example we have used delete this, after deleting this we are trying to access the member of the class, which is not accessible because we have deleted this pointer. i.e. any member of the deleted object was not be accessed after deletion.

NOTE:  The very best practice for the C++ programmer is not do delete this at any time.