fork(102) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void operator delete(void* ptr) { free(ptr); }
  6. void* operator new(size_t sz) {
  7. void *dst=malloc(sz);
  8. if (dst) memset(dst,0xFF,sz);
  9. return dst;
  10. }
  11.  
  12. struct A { int x; A() {} };
  13. struct B : A { int y; A a; };
  14.  
  15. int main(int argc,char** argv) {
  16. A *a=new A();
  17. B *b=new B();
  18.  
  19. printf("a->x=%d\n",a->x);
  20. printf("b->x=%d\n",b->x);
  21. printf("b->y=%d\n",b->y);
  22. printf("b->a.x=%d\n",b->a.x);
  23.  
  24. delete b;
  25. delete a;
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
a->x=-1
b->x=-1
b->y=0
b->a.x=-1