Please consider the following code:
class foo { public: foo(){} ~foo(){} void done() { delete this;} private: int x; };
What is
Both would cause an error.
The first pointer is deleted twice, with the second delete causing the error whereas the second one is allocated on the stack and cannot be implicitly deleted (error caused by first invocation of destructor).
delete