##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# NULL

From cppreference.com
< cpp‎ | types

Defined in header `<cstddef>` |  |
Defined in header `<cstring>` |  |
Defined in header `<cwchar>` |  |
Defined in header `<ctime>` |  |
Defined in header `<clocale>` |  |
Defined in header `<cstdio>` |  |
#define NULL /*implementation-defined*/ |  |

Defines the null pointer constant, which is an integral constant expression prvalue of integer type that evaluates to zero or a prvalue of type std::nullptr_t. The null pointer constant may be implicitly converted to any pointer type; such conversion results in the null pointer value of that type. If the null pointer constant has integer type, it may be converted to a prvalue of type std::nullptr_t.

### [edit] Possible implementation

    #define NULL 0
    //since C++11
    #define NULL nullptr

### [edit] Notes

In C, the macro `NULL` may have the type `void*`, but that is not allowed in C++.

### [edit] Example

Run this code

    #include <cstddef>
    class S;
    int main()
    {
        int* p = NULL;
        int* p2 = static_cast<std::nullptr_t>(NULL);
        void(*f)(int) = NULL;
        int S::*mp = NULL;
        void(S::*mfp)(int) = NULL;
    }

### [edit] See also

nullptr | the pointer literal which specifies a null pointer value (C++11) [edit]
nullptr_t (C++11) | the type of the null pointer literal `nullptr` (typedef) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/types/NULL&oldid=66600"