What will happen when I call a member function on a NULL object pointer?

Posted by Rajendra Kumar Uppal on Stack Overflow See other posts from Stack Overflow or by Rajendra Kumar Uppal
Published on 2010-03-28T15:46:26Z Indexed on 2010/05/28 17:02 UTC
Read the original article Hit count: 178

Filed under:
|

I was given the following as an interview question:

class A
{
public:
    void fun()
    {
        std::cout << "fun" << std::endl;
    }
};

A* a = NULL;
a->fun();

What will happen when this code is executed, and why?

© Stack Overflow or respective owner

Related posts about c++

Related posts about interview-questions