It is possible to specify that a pointer doesn’t point anywhere, by setting the pointer to the literal 0, or the alias NULL defined as 0 in the cstdlib header.
The nullptr is a C++11 literal that can be converted to any other pointer type.
nullptr is always a pointer type, NULL is not.
Where we have overloaded operators, so the same function with different arguments, we don’t have the problem of giving the function a null pointer and having it treated as a integer 0 provided we are using nullptr.
There will be more on pointers later in the subject, including topics such as smart pointers, which are used for handling dynamic objects.
For now, consider how they may be useful in sorting.
Consider that have 1000 large records that we are wanting to order.
Rather than swapping the records, we can swap the relatively small pointers instead.
Generally passing by reference is safer.
Pointers can be null and can be reassigned, references cannot be either.
Unless it actually makes sense to allow for the possibility of the parameter being null, or you want to change where something points, it’s better to use constant or non-constant references to pass arguments.
Note that references are generally going to be implemented using pointers.