title: memory layout in multiple inheritance
body: <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  struct Left
  {
     char i = 'k';
  };
  
  struct Right
  {
     int a = 99;
  };
  
  class Bottom : public Left, public Right
  {};
  
  int main()
  {
      Bottom b;
  
      Left l = b;
      cout &lt;&lt; l.i;
  
      Right r = b;
      cout &lt;&lt; r.a;
  
      return 0;    
  }
  // output
  // k99
  </code></pre>
  
  <p>How did this work?</p>
  
  <p>if the memory layout of Bottom is:</p>
  
  <pre><code>Left
  Right
  Bottom
  </code></pre>
  
  <p>Then slicing <code>b</code> (i.e. <code>Bottom</code>) to <code>Left</code> object, should be ok, but how can it work when I slice <code>Bottom</code> to <code>Right</code> object?</p>
  
  <p>Note: all this would be ok if I used casting. But I did not.</p>