title: Structure Binding : binding to public data members (inherited base class )
body: <p>Even though both bases class and derived class has public data members </p>
  
  <pre><code>#include &lt;iostream&gt;
  class M {
      public:
      int x = 2;
      volatile double y=3;
  };
  
  class S:public M {
      public:
      int x1 = 4 ;
      volatile double y1 = 5;
  
  };
  
  int main() {
      S f();
      S a;
      std::cout&lt;&lt;a.x&lt;&lt;a.y&lt;&lt;a.x1&lt;&lt;a.y1;
      auto [b,c,d,e] = f(); 
  }
  </code></pre>
  
  <p>Getting error for  </p>
  
  <pre><code> auto [b,c,d,e] = f(); 
  </code></pre>
  
  <blockquote>
    <p>main.cpp: In function 'int main()': main.cpp:21:10: error: cannot
    decompose class type 'S': both it and its base class 'M' have
    non-static data members
         auto [b,c,d,e] = f();</p>
  </blockquote>
  
  <p>As per <a href="http://en.cppreference.com/w/cpp/language/structured_binding" rel="noreferrer">http://en.cppreference.com/w/cpp/language/structured_binding</a></p>
  
  <p>Case 3: <strong>binding to public data members</strong></p>
  
  <p>Every non-static data member of E must be a public direct member of E or the <em>same unambiguous public base of E</em>, </p>
  
  <p>Not able to understand what does this mean 
  <em>same unambiguous public base of E</em>, </p>
  
  <p><a href="http://coliru.stacked-crooked.com/view?id=f823741613c5df3d" rel="noreferrer">DEMO</a></p>