title: Function overriding in C++ works without 'virtual'
body: <p>I have a class that contains some functions (none are virtual) and 2 more classes publicly inherit that class. In both the sub classes I override the same function of the base class.</p>
  
  <p>After creating objects of all three classes in main (located at the same file), I call the original function with the baseclass object and the overridden functions with the derivedclass objects.</p>
  
  <p>I was expecting all 3 function calls to run the original function from the base class (since I didn't use 'virtual' anywhere in the code), but I actually get each version of that function working according to the class in which it was defined (3 different versions).</p>
  
  <p>I have the classes Base &amp; Derived as follows:</p>
  
  <pre><code>struct Base
  {
     void foo();
  };
  
  struct Derived : Base
  {
     void foo();
  };
  </code></pre>
  
  <p>in main:</p>
  
  <pre><code>int main()
  {
     Derived d;
     d.foo();
  }
  </code></pre>
  
  <p>I thought d.foo() should run Base::foo() if not using 'virtual'.</p>