C++ nullptr Keyword
Example
Check if a pointer points to anything:
int* ptr = nullptr;
if (ptr == nullptr) {
cout << "ptr does not point to anything";
}
Definition and Usage
The nullptr keyword is a pointer value that does not point to anything. It is called a null pointer.
Give a pointer the value nullptr when it does not point to a variable yet. Then you can check it with == before you use it.
Related Pages
Read more about pointers in our C++ Pointers Tutorial.