--- In c-prog@yahoogroups.com, Thomas Hruska <thru...@...> wrote: > > Jimmy Johnson wrote: > > --- In c-prog@yahoogroups.com, Paul Herring <pauljherring@> wrote: > >> > >>> What should it be. And I hope you don't say > >>> p = 0; > >> Why not? It means _exactly_ the same thing in most contexts in both C and > >> C++. > >> > > > > Because I don't think of a pointer as a boolean, no matter the context. > > Actually, there is a 'bool' type in C++. But I understand the point. > I'm old-school and prefer NULL assignments and comparisons. In C, you > never assumed that NULL was 0. Everyone seems to have settled on that > value as invalid these days, so C++ probably adopted it (too lazy to > look it up in the Rationale). > > > I've noticed most people are saying NULL is defined as: > > #define NULL 0 > > I've also seen (probably C): > > #define NULL ((void *)0) > > -- > Thomas Hruska > CubicleSoft President > Ph: 517-803-4197 > > *NEW* MyTaskFocus 1.1 > Get on task. Stay on task. > > http://www.CubicleSoft.com/MyTaskFocus/ >
An excerpt from Bjarne Stroustrup's C++ Style and Technique FAQ Should I use NULL or 0? In C++, the definition of NULL is 0, so there is only an aesthetic difference. I prefer to avoid macros, so I use 0. Another problem with NULL is that people sometimes mistakenly believe that it is different from 0 and/or not an integer. In pre-standard code, NULL was/is sometimes defined to something unsuitable and therefore had/has to be avoided. That's less common these days. If you have to name the null pointer, call it nullptr; that's what it's going to be called in C++0x. Then, "nullptr" will be a keyword. http://209.85.135.132/search?q=cache:http://www2.research.att.com/~bs/bs_faq2.html