NULL identifier

NULL identifier

A null pointer has a set value called a null pointer constant to indicate that the cursor does not point to any valid object or function. You can use blank references in the following cases:

  • Initialise pointer
  • Represents situations such as end of lists of unknown lengths
  • Show errors in retrieving the pointer from the function

A null pointer is a fixed number that evaluates to zero. For example, a fixed null pointer could be 0, NULL, or such a stream cannot be broadcast to type (empty *) 0. C ++ 11 defines a new fixed null pointer that can be converted to any type of cursor, point-to-member type, or bool type

You can specify any of the following null pointer constant values:

  • 0
  • NULL
  • nullptr
  • NOTE: You must define NULL before use

    Null pointer constant


    You can use a fixed number sentence with the value 0 or a slash in (empty *) 0 as a null pointer constant.


The macro NULL and the value of 0 are equal to the empty indicators, but NULL is pure because it represents the purpose of constant use of the identifier.C ++ 11 startup only.


Nullptr is a null and void identifier. In C ++, launching empty point 0 or NULL has the following problems:

  • It is not possible to distinguish between a null pointer and the 0 number of overloaded functions. For example, in the case of two overloaded functions f(int) and f(char *), the call f(0) solves in f(int) because 0 is converted to a critical type instead of an index type.
  • The null pointer constant does not have a type-safe name. Macro NULL cannot be separated from 0 always with the most complete functions and error detection.

To solve the problems of null pointer constants, C ++ 11 introduced a new keyword nullptr. A fixed nullptr can be separated from the 0 most overloaded functions.