title: Multiple inheritance without virtual functions in c++
body: <p>I came across the diamond problem and found different solutions for different cases with a single diamond. However I couldn't find a solution for 'chained' diamonds.</p>
  
  <p>According to the structure: yes, I want to have multiple baseclasses everytime, so virtual inheritance isn't a solution (is it even called diamond then?). I also wanted to avoid get/set-functions for every middle-layer of a diamond.</p>
  
  <pre><code>p   p
  |   |
  k   k
   \ /
    s
  
  class parent { int val; };
  class kid1 : public parent {};
  class kid2 : public parent {};
  class school : public kid1, public kid2 {};
  </code></pre>
  
  <p>Accessing val in the parent class works now like follows:</p>
  
  <pre><code>school* s = new school;
  s-&gt;kid1::val=1; // works
  </code></pre>
  
  <p>But what about the next 'chained' diamond:</p>
  
  <pre><code>p   p   p   p
  |   |   |   |
  k   k   k   k
   \ /     \ /
    s       s
    |       |
    c       c
      \   /
        w
  
  class country1 : public school {};
  class country2 : public school {};
  class world : public country1, public country2 {};
  </code></pre>
  
  <p>Accessing val via:</p>
  
  <pre><code>world* w = new world;
  w-&gt;country1::kid1::val=1; // error
  </code></pre>
  
  <p>results in: </p>
  
  <pre><code>error: ‘kid1’ is an ambiguous base of ‘world’
  </code></pre>
  
  <p>Why? Isn't the route to the value well defined?</p>