Mail Archives: djgpp/1997/02/22/18:12:53
Mark T Logan wrote:
> char *ptr = NULL;
>
> delete ptr;
>
> Will anything bad happen? I have written the linked list to be as simple
> as
> possible, and as such only one node will ever have a pointer in it
> pointing
> to NULL. This node is the dummy node at the beginning of the list, and I
> end up calling delete on it in one of my destructors.
No. Deleting the null pointer is guaranteed to be safe in C++.
> Do I need to avoid this? Will this become some horrific bug much later
> in
> my project?
If it does, then it's a bug in your compiler.
--
Erik Max Francis, &tSftDotIotE / email: max AT alcyone DOT com
Alcyone Systems / web: http://www.alcyone.com/max/
San Jose, California, United States / icbm: 37 20 07 N 121 53 38 W
\
"I am become death, / destroyer of worlds."
/ J. Robert Oppenheimer (quoting legend)
- Raw text -