fork(4) download
  1. #include <iostream>
  2. #include <exception>
  3.  
  4. class A {
  5. public:
  6. virtual ~A() {
  7. std::cout << "~A()" << std::endl;
  8. }
  9. };
  10.  
  11. class B: public A {
  12. public:
  13. ~B() {
  14. std::cout << "~B()" << std::endl;
  15. throw std::exception();
  16. }
  17. };
  18.  
  19.  
  20. int main() {
  21. A* a = new B();
  22. delete a;
  23. return 0;
  24. }
  25.  
Runtime error #stdin #stdout #stderr 0s 3476KB
stdin
Standard input is empty
stdout
~B()
stderr
terminate called after throwing an instance of 'std::exception'
  what():  std::exception