fork(1) download
  1. #include <cstdlib>
  2. #include <cstdio>
  3.  
  4. class A
  5. {
  6. public:
  7. virtual void f()
  8. {
  9. printf("A.f");
  10. }
  11. A(){f();}
  12. };
  13.  
  14. class B: public A
  15. {
  16. public:
  17. B(){throw -1;}
  18. void f()
  19. {
  20. printf("B.f");
  21. }
  22. ~B(){ f();}
  23. };
  24.  
  25. class C: public A
  26. {
  27. B b;
  28. void f(){ printf("C.f");}
  29. ~C(){f();}
  30. };
  31.  
  32. int main()
  33. {
  34. try
  35. {
  36. A * a = new C();
  37. delete a;
  38. }
  39. catch(...)
  40. {
  41. printf(" Exc ");
  42. }
  43. return 0;
  44. }
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
A.fA.f Exc