R
Roger Davis
I've been reading lately about the necessity of using
delete[] p;
instead of
delete p;
whenever p was allocated as an array, e.g.,
p= new int[20];
I assume this is true even when p is an array of one element, e.g.,
p= new int[1];
Can anyone verify this?
Has this distinction between 'delete[] p' and 'delete p' always
existed in C++? Somehow I missed this point and have been programming
using only 'delete p' for years, with no apparent ill effects. Have I
just been amazingly lucky?
Thanks.
delete[] p;
instead of
delete p;
whenever p was allocated as an array, e.g.,
p= new int[20];
I assume this is true even when p is an array of one element, e.g.,
p= new int[1];
Can anyone verify this?
Has this distinction between 'delete[] p' and 'delete p' always
existed in C++? Somehow I missed this point and have been programming
using only 'delete p' for years, with no apparent ill effects. Have I
just been amazingly lucky?
Thanks.