title: WHY does an uninitialised pointer work in C++ programs?
body: <p>Guys plz check the code below:</p>
  
  <pre><code>class Human
  { 
  public:
      void chat(Human h)
      {
          cout &lt;&lt; "human";
      }
  
      void chat(ComputerScientist c)
      {
          cout &lt;&lt; "computer";
      }
  };
  
  class ComputerScientist : public Human
  {
  };
  
  //Main function below
  int main()
  {
      Human* p, p1;
      //Uninitialized pointer above;
  
      p-&gt;chat(p1); //It shows perfectly the result without ANY error!
  }
  </code></pre>
  
  <p>However, things go tricky if I make a function in derived class ComputerScientist which overrides the Human's one.</p>
  
  <pre><code>class Human
  {
  public:
      virtual void chat(Human* h)
      {
          cout &lt;&lt; "about the weather";
      }
  
      virtual void chat(ComputerScientist* c)
      {
          cout &lt;&lt; "about their own computer illiteracy";
      }
  };
  
  class ComputerScientist : public Human
  {
  public:
      virtual void chat(Human* h)
      {
          cout &lt;&lt; " about computer games";
      }
  
      virtual void chat(ComputerScientist* c)
      {
          cout &lt;&lt; " about others’ computer     illiteracy";
      }
  };
  </code></pre>
  
  <p>And I use the same main function, it appears to be a segmentation fault in the null pointer line. But why?</p>
  
  <p>Things have make change in two places in the second example:</p>
  
  <ol>
  <li>I used the overriding function by making it virtual.</li>
  <li>The function is taking a pointer as argument.</li>
  </ol>