Namespaces
Variants
Views
Actions

NULL

From cppreference.com
< cpp‎ | types
Revision as of 18:35, 2 November 2012 by P12bot (Talk | contribs)

 
 
 
Type support
Basic types
Fundamental types
Fixed width integer types (C++11)
(C++11)
NULL
Numeric limits
C numeric limits interface
Runtime type information
Type traits
Primary type categories
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Type properties
(C++11)
(C++11)
(C++11)
(C++14)
Supported operations
Relationships and property queries
(C++11)
(C++11)
(C++11)
(C++11)
Type modifications
(C++11)(C++11)(C++11)
Type transformations
(C++11)
(C++11)
(C++11)
Type trait constants
 

Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <cstddef>
</td>

<td></td> <td></td> <tr class="t-dsc-header">

<td>
Defined in header <cstring>
</td>

<td></td> <td></td> <tr class="t-dsc-header">

<td>
Defined in header <cwchar>
</td>

<td></td> <td></td> <tr class="t-dsc-header">

<td>
Defined in header <ctime>
</td>

<td></td> <td></td> <tr class="t-dsc-header">

<td>
Defined in header <clocale>
</td>

<td></td> <td></td> <tr class="t-dsc-header">

<td>
Defined in header <cstdio>
</td>

<td></td> <td></td> <tr class="t-dcl ">

<td class="t-dcl-nopad">
#define NULL /*implementation-defined*/
</td>

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end

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.

Possible implementation

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

Example

#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;
}


See also

Template:cpp/language/dcl list nullptr
(C++11)
the type of the null pointer literal nullptr
(typedef) [edit]