As far as I understand, C++ does not require NULL to be zero.
NULL is #defined as 0, meaning there's absolutely no difference except style/personal preference, and Bjarne "C++" Stroustrup was quoted earlier as preferring 0 (or nullptr in C++11 where available) over the NULL macro.
It can be any integer beside 0.
I can not remember where I read, but on some embed system, NULL can be a value different than zero.
So he is correct.
Not in a standard complying C++ implementation. The C++ standard requires NULL
to evaluate to zero (that is, NULL
== 0 is always true). Embedded systems implementations sometimes break the rules of C++, so they're not exactly the best reference. If you don't believe me, read the C++ Standard
:Section 18.2, paragraph 3
: The macro NULL is an implementation-deﬁned C++ null pointer constant in this International StandardSection 4.10, paragraph 1
: A null pointer constant is an integral constant expression prvalue of integer type that evaluates to zero or a prvalue of type std::nullptr_t
is required to be a "null pointer constant" and a "null pointer constant is an integral constant expression [...] that evaluates to zero" we can deduct that NULL
evaluates to zero.