#include <stdio.h>
class Foo {
public:
Foo(char x);
Foo(char x, int y);
~Foo();
void abc();
void dev();
};
void Foo::dev()
{
printf("inside dev \n");
}
void Foo::abc()
{
printf("inside abc \n");
delete this;
dev();
}
Foo::Foo(char x)
{
printf("inside 1 argu const---------------");
}
Foo::~Foo()
{
printf("inside 1 argu dest---------------");
}
#include "test.h"
int main()
{
Foo *obj=new Foo('a');
printf("%u inside main\n", obj);
obj->abc();
return 0;
}
After looking at the output of the program, it seems that "dev" function is still invoked despite being "delete this" is called in function abc before invoking dev ? How does gcc/g++ handles this ?