Can i call destructor from its class method?

c++, destructor

Solution

Technically yes, but be careful, you should not use the deleted object, `this` and non-static members anymore:

delete this;

You can also call the destructor:

~Thread();

However, in a well designed code, you can avoid these types of self destructions.

Problem

I have a Thread class like bellow ``` class Thread { public: Thread(); ~Thread(); void start(); void stop(); } ``` So i need to call destructor from stop() method, is it a good way to do that?

Original source

Related problems