C standard says :
6.3.2.3/3 Pointers
An integer constant expression with the value 0, or such expression
cast to type void *
, is called a null pointer constant.
stddef.h
then contains the NULL
-define to that value.
C++ (another language, roughly related to C, certainly not in the way people usually think) used NULL
in its very early versions (don't use it!). But in pre-C++11 releases, the constant 0
was defined as the way to represent pointers to nothing. Alas, this has some serious drawbacks and then C++11 defined the nullptr
constant. Note that nullptr
is a keyword.
C++ standard says:
2.14.17/1 Pointer literals
The pointer literal is the keyword nullptr
. It is a prvalue of type std::nullptr_t
. [ Note: std::nullptr_t
is a distinct type that is neither a pointer type nor a pointer to member type; rather, a prvalue of this type is a null pointer constant and can be converted to a null pointer value or null member pointer value.]
3.9.1/10 Fundamental types
A value of type std::nullptr_t
is a null pointer constant. Such
values participate in the pointer and the pointer to member
conversions. sizeof(std::nullptr_t)
shall be equal to
sizeof(void*)
.
About NULL
in C++ standard says:
18.2/3 Types
The macro NULL
is an implementation-defined C++ null pointer constant.