C + + tells us to use delete[] when reclaiming the memory space of a single object allocated with new and using Delete to reclaim the memory space of a set of objects allocated with new[].
About new[] and delete[], which are divided into two cases : (1) Allocate and reclaim space for basic data Types , and (2) allocate and reclaim space for custom types .
Basic types of objects do not have destructors, so it should be possible to reclaim the array space of basic types with delete and delete[] , but only with delete[] for an array of class objects.
So a simple use principle is: New and delete, new[] and delete[] corresponding to use.
Title: Use char* p = new char[100] To apply for a piece of memory, then use delete p to release, what's the problem?
There will be memory leaks.
There is no memory leak, but it is not recommended
Compile will be error, must use delete []p;
Compile no problem, run will crash directly
About Delete and delete[]