title: Why does calling method through null pointer "work" in C++?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2505328/calling-class-method-through-null-class-pointer">Calling class method through NULL class pointer</a>  </p>
  </blockquote>
  
  
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  class test
  {
      int i;
  public:
      test():i(0){ cout &lt;&lt; "ctor called" &lt;&lt; endl;}
      void show()
      {
          cout&lt;&lt;"show fun called"&lt;&lt;endl;
      }
  };
  
  int main(int argc , char *argv[])
  {
      test *ptr = NULL;
      ptr-&gt;show();
      return 0;
  }
  </code></pre>
  
  <p>clearly, no ctor will be called. Is this standard? or just some compiler optimization as this pointer is not used in show() member function?</p>