fork download
  1. #include <iostream>
  2.  
  3. class Object
  4. {
  5. public:
  6. Object(void){ static unsigned counter = 0; number = counter++; }
  7. ~Object(void){ std::cout << number << " has been destroyed!" << std::endl; }
  8.  
  9. private:
  10. unsigned number;
  11. };
  12.  
  13. int main()
  14. {
  15. Object *obj = new Object[100];
  16. delete[50] obj;
  17. return 0;
  18. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:16:9: error: expected ‘]’ before numeric constant
  delete[50] obj;
         ^
prog.cpp:16:9: error: type ‘int’ argument given to ‘delete’, expected pointer
prog.cpp:16:11: error: expected ‘;’ before ‘]’ token
  delete[50] obj;
           ^
prog.cpp:15:10: warning: unused variable ‘obj’ [-Wunused-variable]
  Object *obj = new Object[100];
          ^
stdout
Standard output is empty