class Foo
{
public:
Foo(int i)
{
_i = i;
}
void p()
{
cout<<"printed"<<endl;
}
int _i;
};
int main()
{
Foo *p = 0;
cout <<p<<endl;
p->p();
return 0;
}
The actual output of above code is
0
printed
As per my understanding it should give SEG fault for accessing 0x0 addess. Because the *p address is 0x0.
Why it is working ?anybody explain it ?