title: Inherit from two polymorphic classes
body: <p>Given the following code</p>
  
  <pre><code>class T {
      public:
          virtual ~T () {}
          virtual void foo () = 0;
  };
  
  class U {
      public:
          U() {}
          ~U() {}
          void bar () { std::cout &lt;&lt; "bar" &lt;&lt; std::endl; }
  };
  
  class A : public U, public T {
      public:
          void foo () { std::cout &lt;&lt; "foo" &lt;&lt; std::endl; }
  };
  
  int main () {
      A * a = new A;
  
      std::vector&lt;U*&gt; u;
      std::vector&lt;T*&gt; t;
  
      u.push_back(a);
  
      t.push_back(reinterpret_cast&lt;T*&gt;(u[0]));
  
      u[0]-&gt;bar ();
      t[0]-&gt;foo ();
  
      delete a;
      return 0;
  }
  </code></pre>
  
  <p>I get the output I would expect</p>
  
  <pre><code>bar
  foo
  </code></pre>
  
  <p>However, if I change the definition of <code>U</code> to</p>
  
  <pre><code>class U {
      public:
          U() {}
          virtual ~U() {}
          virtual void bar () { std::cout &lt;&lt; "bar" &lt;&lt; std::endl; }
  };
  </code></pre>
  
  <p>I still compile fine and without warnings/errors but the output is now</p>
  
  <pre><code>bar
  bar
  </code></pre>
  
  <p>What is it about the virtual declaration that prevents me from calling into the <code>foo</code>?</p>