As I understand if the member function has been called using pointer to an object which is allocated dynamically, the object would get delete. But if the member function has been called using the object, which is allocated statically, then what will happen ?
class sample
{
int i;
public:
void func()
{
delete this;
}
};
void main()
{
sample *s = new sample;
s->fun();
sample s1;
s1.fun();
}