title: Virtual Table C++
body: <p>I read a lot of people writing "a virtual table exists for a class that has a virtual function declared in it".</p>
  
  <p>My question is, does a vtable exists only for a class that has a virtual function or does it also exist for classes derived from that class. </p>
  
  <p>e.g</p>
  
  <pre><code>class Base{
      public:
          virtual void print(){cout&lt;&lt;"Base Print\n";}
  };
  class Derived:public Base{
      public:
          void print(){cout&lt;&lt;"Derived print\n";}
  };
  
  //From main.cpp 
  Base* b = new Derived;
  b-&gt;print();
  </code></pre>
  
  <p>Question: Had there been no vtable for class derived then the output would not have been "derived print". So IMO there exists a vtable for any class that has virtual function declared and also in classes inheriting from that class. Is this correct ?</p>