fork(1) download
  1. #include <iostream>
  2.  
  3. struct B {int i; };
  4. struct B2 {int j;};
  5. struct D : B2, B {};
  6.  
  7. int main()
  8. {
  9. D obj;
  10. D* d = &obj;
  11. B* b = &obj;
  12.  
  13. std::cout << "Base : " << b << std::endl;
  14. std::cout << "Derived : " << d << std::endl;
  15. D* r = reinterpret_cast<D*>(b);
  16. std::cout << "reinterpret_cast: " << r << std::endl;
  17. D* s = static_cast<D*>(b);
  18. std::cout << "static_cast : " << s << std::endl;
  19. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
Base            : 0xbf84973c
Derived         : 0xbf849738
reinterpret_cast: 0xbf84973c
static_cast     : 0xbf849738