fork download
  1. #include <cassert>
  2.  
  3. struct A { int x;};
  4. struct B : public A {};
  5. struct C : public A {};
  6.  
  7. struct D : B, C
  8. {
  9. D () {
  10. C::x = 2;
  11. B::x = 3;
  12. assert(static_cast<C&>(*this).x == 2);
  13. assert(static_cast<B&>(*this).x == 3);
  14. assert(&static_cast<C&>(*this).x == &(C::x));
  15. assert(&static_cast<B&>(*this).x == &(B::x));
  16. }
  17. };
  18.  
  19. int main () { D d; }
Success #stdin #stdout 0s 2892KB
stdin
Standard input is empty
stdout
Standard output is empty