fork download
  1. #include <iostream>
  2.  
  3. using std::cout;
  4.  
  5. struct A
  6. {
  7. int a;
  8. char b;
  9. A(){ a = 4; }
  10. };
  11.  
  12. struct B
  13. {
  14. int c;
  15. B(){ c = 5; }
  16. };
  17.  
  18. A *a = new A;
  19. B *b = new B;
  20.  
  21. int main()
  22. {
  23. a = reinterpret_cast<A*>(b);
  24. cout << a -> a; //5
  25. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
5