
- Forum
- Programming Talk
- C and C++
- Problem with Deleting
Problem with Deleting
This is a discussion on Problem with Deleting within the C and C++ forums, part of the Programming Talk category; In C++ we have delete to delete objects once the object is finished using. I want to delete an array ...
-
Problem with Deleting
In C++ we have delete to delete objects once the object is finished using. I want to delete an array of objects given below
char *e = new char[50];
For doing this when I gave delete I got error message from compiler. Why is it so? Can’t I use delete to delete the above array of objects? Someone kindly troubleshoot this error.
-
You have got the error in your program because you have made used to delete. But for deleting array of objects you have to use delete[]. Only for deleting an object we use delete but for deleting array of object one must make use of delete[].So replace delete with delete[] in your program and your program would execute successfully.

Reply With Quote





