fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A {
  5. A() { cout << "A()" << endl; }
  6. A(const A &a) { cout << "A(const A&)" << endl; }
  7. virtual ~A() { cout << "~A()" << endl; }
  8. };
  9.  
  10. int main() {
  11. A a;
  12. try {
  13. throw a;
  14. } catch (A &a) {
  15. cout << "Caught" << endl;
  16. }
  17. cout << "After catch" << endl;
  18. return 0;
  19. }
Success #stdin #stdout 0.01s 2812KB
stdin
Standard input is empty
stdout
A()
A(const A&)
Caught
~A()
After catch
~A()