fork download
  1. #include <iostream>
  2. #include <exception>
  3. #include <stdexcept>
  4. using namespace std;
  5.  
  6. class Int {
  7. public:
  8. int v;
  9. Int(int a) : v(a) {}
  10. };
  11.  
  12. void a() {
  13. throw 0;
  14. }
  15.  
  16. void b() {
  17. try {
  18. a();
  19. } catch(int i) {
  20. throw Int(i + 1);
  21. }
  22. }
  23.  
  24. void c() {
  25. try {
  26. b();
  27. } catch(...) {
  28. throw;
  29. }
  30. }
  31.  
  32. int main(void) {
  33. try {
  34. c();
  35. } catch(Int &i) {
  36. cout << i.v;
  37. }
  38. return 0;
  39. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
1