fork download
  1. #include <stdio.h>
  2. #include <iostream>
  3. using namespace std;
  4. class A {
  5. public:
  6. ~A() {
  7. try {
  8. printf("exception in A start\n");
  9. throw 30;
  10. printf("exception in A end\n");
  11. }catch(int e) {
  12. printf("catch in A %d\n",e);
  13. }
  14. }
  15. };
  16. class B{
  17. public:
  18. ~B() {
  19. printf("exception in B start\n");
  20. throw 20;
  21. printf("exception in B end\n");
  22. }
  23. };
  24. int main(void) {
  25. try {
  26. A a;
  27. B b;
  28. }catch(int e) {
  29. printf("catch in main %d\n",e);
  30. }
  31. return 0;
  32. }
  33.  
Runtime error #stdin #stdout #stderr 0s 3468KB
stdin
Standard input is empty
stdout
exception in B start
stderr
terminate called after throwing an instance of 'int'