title: Explanation of virtual table
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5712808/understanding-the-vtable-entries">Understanding the vtable entries</a>  </p>
  </blockquote>
  
  
  
  <p>Using g++ version 4.6.3, 64-bit machine . I know compiler is free to implement virtual functions any way it wants. I want to know what happened here.</p>
  
  <p>My class:</p>
  
  <pre><code>#include &lt;iostream&gt;
  class test
  {
      public:
      virtual void func(){std::cout&lt;&lt;"in class test";}
  };
  
  int main()
  {
      test obj;
      obj.func();
      return 0;
  }
  </code></pre>
  
  <p>Looking at virtual table generated by compiler,</p>
  
  <pre><code>Vtable for test
  test::_ZTV4test: 3u entries
  0     (int (*)(...))0 (&lt;---- what is this? )
  8     (int (*)(...))(&amp; _ZTI4test)
  16    (int (*)(...))test::func
  </code></pre>
  
  <p>At offset 8 it is RTTI </p>
  
  <p>At offset 16 it is entry for virtual function.</p>
  
  <p>My question is why is there entry for NULL at offset 0 or in other words what is the purpose of first entry? </p>
  
  <p>P.S. I thought this could be related to alignment, but then I added more virtual functions but RTTI entry was still at offset 8.</p>