Having this:
class Foo
{
public:
void destroy() { delete this; }
public:
// Stuff here...
};
int main(int argc, char *argv[])
{
Foo* foo = new Foo;
// Option 1
delete foo;
// Option 2:
foo->destroy();
return 0;
}
Is Option 1 and Option 2 the same operation? Is it a 'correct' way for destroying objects? Why/Why not?
Thank you so much,