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
Post a Comment