fork download
  1. #include <iostream>
  2.  
  3. class XX
  4. {
  5. public:
  6. XX() {
  7. std::cout<<"C XX\n";
  8. if (++instCount > 4) {
  9. throw "Fuck you, I'm not gonna create more than 4 instances";
  10. }
  11. }
  12. //private:
  13. ~XX() {
  14. std::cout<<"~ XX\n";
  15. instCount--;
  16. }
  17.  
  18. private:
  19. static int instCount;
  20. };
  21.  
  22. int XX::instCount = 0;
  23.  
  24. int main() {
  25. XX *xx;
  26. try {
  27. xx = new XX[10]; // runtime error (1)
  28. } catch (...) {}
  29.  
  30. return xx ? 0 : 1;
  31. }
  32.  
Runtime error #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
C XX
C XX
C XX
C XX
C XX
~ XX
~ XX
~ XX
~ XX