title: Null pointer in c++
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/669742/accessing-class-members-on-a-null-pointer">Accessing class members on a NULL pointer</a>  </p>
  </blockquote>
  
  
  
  <pre><code>#include&lt;iostream.h&gt;
  class X{
      private:
          int x;
      public:
          X() {}
          void func() {
              cout&lt;&lt;"In func()"&lt;&lt;endl;
          }
  };
  
  int main(void)
  {
      X *x=NULL;
      x-&gt;func();
      return 0;
  }
  </code></pre>
  
  <p>I am really surprised with the o/p ,can anyone please explain me how x can access func().</p>