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

How to logout from a login page in asp.net -

Stack level too deep error after upgrade to rails 3.2 and ruby 1.9.3 -