fork(1) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Base{};
  6. class Derived: public Base {};
  7.  
  8. int main()
  9. {
  10. Derived d;
  11.  
  12. try{
  13. throw d;
  14. }
  15. catch(Base b){
  16. cout<<"Caught Base Exception";
  17. }
  18. catch(Derived d){
  19. cout<<"Caught Derived exception";
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5380KB
stdin
Standard input is empty
stdout
Caught Base Exception