fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Base{
  5. int foo = 1;
  6. };
  7. struct Derived : public Base{
  8. int bar = 2;
  9. };
  10.  
  11. int main() {
  12. Base b;
  13.  
  14. Derived *d = reinterpret_cast<Derived*>(&b);
  15.  
  16. cout << d->bar << endl;
  17.  
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
0