delorie.com/archives/browse.cgi | search |
Message-Id: | <2.2.32.19970217010047.00686a98@mailhost> |
Mime-Version: | 1.0 |
Date: | Sun, 16 Feb 1997 23:00:47 -0200 |
To: | djgpp AT delorie DOT com |
From: | Eyal Ben-David <eyalb AT aks DOT com> |
Subject: | Re: delete NULL? |
> I just finished writing a C++ implementation of a circular linked list. > > My question is this. If I use delete on a pointer which is equal to > NULL, > for example... > > char *ptr = NULL; > > delete ptr; > 1. It is not recommended to use NULL in C++. Use 0 (zero) instead. ANSI C does not force the identity NULL == 0. In C++ the null pointer is ALWAYS 0. 2. "delete 0" has no effect ==> You don't have to test the pointer.
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |