method gets called with null pointer
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2505328/calling-class-method-through-null-class-pointer">Calling class method through NULL class pointer</a>  </p>
</blockquote>



<p><strong>How is the below program giving output?</strong></p>

<pre><code>class A
{
    public:
    void dosomething()
    {
        std::cout &lt;&lt;"hello world";
    }
};
int main()
{
    A *ptr =NULL;
    ptr-&gt;dosomething(); &lt;---------------- outputs hello world
    return 0;
}
</code></pre>

<p><a href="http://ideone.com/oLtJN" rel="nofollow">http://ideone.com/oLtJN</a></p>

<p>Shouldn't the program crash as the <code>dosomething()</code> is called by the <code>null pointer</code>.</p>
