[Cs3] on (mis) use of pointers to dynamically allocated arrays
Mikhail Nesterenko
mikhail at cs.kent.edu
Fri Jan 24 01:01:56 EST 2014
There was a question in class about using
delete [] p;
Whether "p" has to be an array pointer. As per standard, "p" has to be
pointing to a previously dynamically allocated array. If "p" points to
anything else, the behavior of "delete" is unspecified
(unpredictable).
Similarly if "p", points to a dynamically allocated array and
delete p;
(without square brackets) is used, the behavior is also unspecified.
Thanks,
--
Mikhail
More information about the cs3
mailing list