[cs13001] FW: CS-13001-006-201480: CS I PROGRAM/PROBLEM SOLVING: Experiment with Delete

Mikhail Nesterenko mikhail at cs.kent.edu
Tue Oct 28 20:43:37 EDT 2014


> 
> You asked me to send you an e-mail regarding what happens if delete
> is used on automatic memory so you could try it.


The operator "delete" as well as "delete[]" may only be invoked with a
pointer to the memory location previously allocated with "new" or
"new[]". Any other use, including invoking "delete" with a pointer
pointing to an automatic memory location leads to unspecified
results. This may possibly corrupt memory and crash your program.

thanks,
--
Mikhail 


More information about the cs13001 mailing list