fork download
  1. #include <cstdio>
  2.  
  3. struct A { int x; };
  4. struct B { int y; };
  5.  
  6. struct C : B, A {};
  7.  
  8. int main() {
  9. void* c = new C();
  10. printf("%p\n", c); // 0x1000
  11. A* a = (A*) c;
  12. printf("%p\n", a); // 0x1000
  13. A* aa = (A*) ((C*) c);
  14. printf("%p\n", aa); // 0x1004
  15. return 0;
  16. }
  17.  
  18.  
  19.  
Success #stdin #stdout 0.01s 2812KB
stdin
Standard input is empty
stdout
0x8805008
0x8805008
0x880500c