The first point: there is practically no reason to use the new or delete array form to start with - use std :: vector (or some other container) instead.
Secondly: in the dark C ++ times, you had to specify the size of the array you were deleting, so if you used x = new T[N] , the corresponding deletion was delete [N] x . The requirement to explicitly specify the size has been removed a long time ago, but some compilers (especially those that care about backward compatibility with ancient code) still allow this.
If you really need to stay compatible with the ancient compiler (which is 20 years old or so), you should not use it. Again, if you do not need to remain compatible with such an old compiler, it does not support standard containers, you should not use the new or delete array form in the first place. Just stop!
Jerry Coffin
source share