fork(1) download
  1. #include <iostream>
  2. struct hello {};
  3.  
  4. struct Thrower {
  5. Thrower() { throw new hello; }
  6. };
  7.  
  8. struct Catcher {
  9. Catcher()
  10. try {
  11. std::cout << "ran\n";
  12. } catch( hello*h ) {
  13. std::cout << "caught!\n";
  14. throw h;
  15. }
  16. Thrower t{};
  17. };
  18. int main() {
  19. try {
  20. Catcher c;
  21. } catch(hello* h) {
  22. std::cout << "caught again\n";
  23. }
  24. // your code goes here
  25. return 0;
  26. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
caught!
caught again