Delete [] operator

Started by
2 comments, last by Xtreme 23 years, 2 months ago
when a delete operator is called to some variable, does that variable get assigned to NULL? For Example: delete [] buffer; frees up the memory held by buffer. So is buffer now assigned to NULL? It seems like in Windows 98/Me it works ok but in Windows NT 4.0 I get an "Access Violation" error whenver I checked for a NULL against the variable after I delete it.
Yes! There are kangaroos in Australia but I haven't seen them...yet
Advertisement
Well in the VC++ documentation all it says is that it frees the memory, nothing about setting it to NULL. Why don''t you just put:

buffer = NULL

after you call delete?



Digital Radiation
Since i didn''t get any run-time errors in Windows Me I left it out. But when I tried it on the Windows NT system, I got the
error!
Yes! There are kangaroos in Australia but I haven't seen them...yet
delete does not reset the variable to NULL. It is good practice to do it yourself though since a common cause of bugs is using a pointer after you''ve deleted it.

-Mike
-Mike

This topic is closed to new replies.

Advertisement