fork download
  1. #include <iostream>
  2.  
  3. int f(){
  4. throw 1;
  5. }
  6.  
  7. class A
  8. {
  9. public:
  10. A() try : _k(f())
  11. {}
  12. catch (int)
  13. {
  14. std::cout << "Exception 1" << std::endl;
  15. }
  16.  
  17. private:
  18. int _k;
  19. };
  20.  
  21. int main(void)
  22. {
  23. try
  24. {
  25. A a;
  26. } catch(int)
  27. {
  28. std::cout << "Exception 2" << std::endl;
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0.01s 2812KB
stdin
Standard input is empty
stdout
Exception 1
Exception 2