0

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;
}

http://ideone.com/oLtJN

Shouldn't the program crash as the dosomething() is called by the null pointer.

4

0 回答 0