Please check this code..
class ex
{
int i;
public:
ex(int ii = 0):i(ii){}
~ex(){cout<<"dest"<<endl;}
void show()
{
cout<<"show fun called"<<endl;
}
};
int main(int argc , char *argv[])
{
ex *ob = NULL;
ob->show();
return 0;
}
what happens when we call show method.
Thanks..
You’re dereferencing a null pointer which causes undefined behaviour. This is bad.
If it’s not clear where the dereference is then understand that the
->operator translates to(*ob).show().