NULL == 0?

Why are people writing "NULL" - it is longer!?
Not only that, but Bjarne Stroustrup specifically recommends the use of 0.
Thanks, is what I've done this far...
closed account (z05DSL3A)
I think the use of NULL comes from the how C handles the null pointer constant; it is often defined along the lines of:
1
2
3
4
5
#if C++
#def NULL 0
#else C
#def NULL ((void*)0)
#end 
NULL!=0, NULL is speciall .I think I have read that in some books.
Last edited on
As an aside, in the upcoming C++0x (although it will most likely end up being C++10), nullptr will be introduced. Unlike NULL, it will be a keyword and have type. Its type will be nullptr_t, which can be implicitly casted to any pointer type. Wikipedia fails to mention its value.

I don't know how I feel about this. It's not a bad idea, but 0 has kinda grown on me.
Just took a look at the wiki site and what not about C++0x - it doesn't look to bad. But I guess time will tell.
closed account (z05DSL3A)
For those interested in reading the most recent C++0x report, N2800, published in October 2008.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2800.pdf
Topic archived. No new replies allowed.