title: Why is there ambiguity in this diamond pattern?
body: <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class A             { public: void eat(){ cout&lt;&lt;"A";} };
  class B: public A   { public: void eat(){ cout&lt;&lt;"B";} };
  class C: public A   { public: void eat(){ cout&lt;&lt;"C";} };
  class D: public B,C { public: void eat(){ cout&lt;&lt;"D";} };
  
  int main(){
      A *a = new D();
      a-&gt;eat();
  }
  </code></pre>
  
  <p>I am not sure this is called diamond problem or not, but why doesn't this work?</p>
  
  <p><em>I have given the defination for <code>eat()</code> for <code>D</code>. So, it doesn't need to use either <code>B</code>'s or <code>C</code>'s copy (so, there should be no problem).</em></p>
  
  <p><strong>When I said, <code>a-&gt;eat()</code> (remember <code>eat()</code> is not virtual), there is only one possible <code>eat()</code> to call, that of <code>A</code>.</strong> </p>
  
  <p>Why then, do I get this error:</p>
  
  <blockquote>
    <p>'A' is an ambiguous base of 'D'</p>
  </blockquote>
  
  <hr>
  
  <p>What exactly does <code>A *a = new D();</code> mean to the compiler??</p>
  
  <p>and</p>
  
  <p>Why does the same problem not occur when I use <code>D *d = new D();</code>?</p>