wrong5.cc 598 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <noduma.h>
  2. #include <iostream>
  3. #include <string>
  4. #include <dumapp.h>
  5. using namespace std;
  6. class Test {
  7. public:
  8. int a;
  9. string stdstr;
  10. Test() {
  11. a=2;
  12. stdstr = "test";
  13. }
  14. };
  15. int main() {
  16. cout << "Hello world!" << endl;
  17. {
  18. Test* pI = new Test[10];
  19. cerr << "Let's delete instead of delete [] " << endl;
  20. delete pI;
  21. cerr << "Did you notice?" << endl;
  22. }
  23. {
  24. Test* pI = new Test[10];
  25. cerr << "Now let's free instead of delete [] " << endl;
  26. free(pI);
  27. cerr << "Did you notice?" << endl;
  28. }
  29. cerr << "There should be 2 errors in this run" << endl;
  30. return 0;
  31. }