c++ - calling a self destructor from inside a method -


i wanted know if possible call destructor of class own method. instance have class foo created such

foo* f = new foo(); 

now suppose foo has method called finalize

void foo::finalize() {    //do finalizing code    //delete instance; } 

is possible finalize call destructor of foo , recover memory allocated new ? if how ?

you can call delete this; delete object within method


Comments

Popular posts from this blog

PHP Error "Undefined index" -

C# List<> to xml -

php - How to only save new tweets/instagram photos to database? -