title: Call an interface function from an unknown derived class (multiple inheritance)
body: <p>I have an array of <code>Base*</code> objects. This holds a bunch of derived objects, some of which may implement an <code>Interface</code>.</p>
  
  <pre><code>struct Base {
      virtual void doNotCallThis() { cout &lt;&lt; "nooo" &lt;&lt; endl; }
  };
  
  struct Interface {
      virtual void doThis() = 0;
  };
  
  // Example derived class
  struct Derived : Base, virtual Interface {
      virtual void doThis() { cout &lt;&lt; "yes" &lt;&lt; endl; }
  };
  
  int main() {
      Base* b[1];
      b[0] = new Derived(); // Here would be a bunch of different derived classes
      ((Interface*)b[0])-&gt;doThis(); // Elsewhere, doThis() would be called for select array elements
      return 0;
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>nooo
  </code></pre>
  
  <p>I don't know the exact type of <code>b[i]</code> at run time, so I can't cast to <code>Derived</code> (it could be <code>Derived2</code>, <code>Derived3</code>, etc). I also can't use dynamic_cast if that's a solution. All I know is that, by the time I call <code>doThis()</code>, <code>b[i]</code> is a type that inherits from <code>Interface</code>. The way I attempted to call it above causes the wrong function to be called, eg. <code>Base::doNotCallThis()</code>.</p>
  
  <p>How can I call it properly?</p>