fork download
  1. #include <cstdio>
  2.  
  3. struct A {
  4. A() { std::printf("A::A() this=%p\n", this); }
  5. ~A() { std::printf("A::~A() this=%p\n", this); }
  6. };
  7.  
  8. struct B : A {
  9. B(int) { std::printf("B::B(int) this=%p\n", this); }
  10. B() : B(1) { std::printf("B::B() this=%p\n", this); throw 1; }
  11. ~B() { std::printf("B::~B() this=%p\n", this); }
  12. };
  13.  
  14. int main()
  15. try {
  16. B b;
  17. }
  18. catch (...) {
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 5508KB
stdin
Standard input is empty
stdout
A::A() this=0x7ffdf9816a67
B::B(int) this=0x7ffdf9816a67
B::B() this=0x7ffdf9816a67
B::~B() this=0x7ffdf9816a67
A::~A() this=0x7ffdf9816a67