fork download
  1. #include <iostream>
  2. #include <memory>
  3.  
  4. struct A{
  5. int n;
  6. A(int a):n(a){std::cout<<"A() :"<<n<<std::endl;}
  7. A(const A& a):n(a.n){ std::cout<<"A(A) :"<<n<<std::endl;}
  8. A& operator=(const A& a){n=a.n; std::cout<<"= :"<<n<<std::endl;}
  9. ~A(){std::cout<<"~A() :"<<n<<std::endl;}
  10. };
  11.  
  12. struct Er{
  13. Er(){throw 0;}
  14. };
  15.  
  16. struct B{
  17. A* a;
  18. Er* b;
  19. A* c;
  20. B(){
  21. /*...*/
  22. }
  23. };
  24.  
  25. int main(){
  26. try{
  27. B b;
  28. }
  29. catch(...){std::cout<<"catch"<<std::endl;}
  30. }
  31.  
Success #stdin #stdout 0s 2880KB
stdin
Standard input is empty
stdout
Standard output is empty