We all know that new and delete, new [] and delete [] must be used in pairs, but not everyone knows what the difference between Delete and delete.
Some people may say that delete is not the object to be deleted, but delete is the object to be deleted. This statement is only half right.
Indeed, delete [] is used to release arrays. What if I use Delete to release arrays? There are two cases:
1. Delete basic data type array
In this case, the effects of Delete and delete [] are the same, and the Array Memory is released.
2. Delete custom data type array
In this case, delete is used to release the Array Memory, but only the destructor of the first object of the array is called. Delete [] not only releases the memory, the destructor of each array object is also called.
The difference between Delete and delete [] is whether to call the destructor of each array object in the array. Therefore, we still use the new, delete, new [], and delete [] pairs.