fork download
  1. #include <iostream>
  2.  
  3. struct base
  4. {
  5. int * i = new int;
  6. void foo()
  7. {
  8. *i = 5;
  9. std::cout << "foo" << std::endl;
  10. }
  11. };
  12.  
  13. struct derived : base {};
  14.  
  15. struct other {};
  16.  
  17. int main()
  18. {
  19. other o;
  20.  
  21. base &bref = reinterpret_cast<base&>(o);
  22. bref.foo();
  23. }
Runtime error #stdin #stdout 0s 4256KB
stdin
Standard input is empty
stdout
Standard output is empty