fork download
  1. #include <iostream>
  2. #include <stdexcept>
  3.  
  4. struct A
  5. {
  6. A() { std::cout << "A()\n"; }
  7. ~A() { std::cout << "~A()\n"; }
  8. };
  9.  
  10. struct B
  11. {
  12. A a1;
  13. B()
  14. {
  15. A a2;
  16. throw std::runtime_error("noooo");
  17. }
  18. };
  19.  
  20. int main()
  21. {
  22. try {
  23. B b;
  24. } catch (std::runtime_error& e) {
  25. std::cout << e.what() << '\n';
  26. }
  27. }
Success #stdin #stdout 0s 2960KB
stdin
Standard input is empty
stdout
A()
A()
~A()
~A()
noooo