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 = NULL;
  26. try
  27. {
  28. xx=new XX[10]; // compile error (1)
  29. }
  30. catch(...)
  31. {
  32. std::cout << "Oops" << std::endl;
  33. }
  34.  
  35. return xx ? 0 : 1;
  36. }
Runtime error #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
C XX
C XX
C XX
C XX
C XX
~ XX
~ XX
~ XX
~ XX
Oops