fork download
  1. #include <iostream>
  2.  
  3. struct My {
  4. static int count;
  5. int id_;
  6.  
  7. My(): id_{count++} {
  8. if (id_ == 10) throw 42;
  9. }
  10.  
  11. ~My() {
  12. std::cout << "~" << id_ << std::endl;
  13. }
  14. };
  15.  
  16. int My::count = 0;
  17.  
  18. int main() {
  19. try {
  20. new My[42];
  21. } catch (...) {
  22.  
  23. }
  24. }
  25.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
~9
~8
~7
~6
~5
~4
~3
~2
~1
~0