Possible Duplicate:
Calling class method through NULL class pointer
How is the below program giving output?
class A
{
public:
void dosomething()
{
std::cout <<"hello world";
}
};
int main()
{
A *ptr =NULL;
ptr->dosomething(); <---------------- outputs hello world
return 0;
}
Shouldn't the program crash as the dosomething()
is called by the null pointer
.