Using nullptr to encode absence.
Using a smart pointer (e.g., shared_ptr) which, again, can be tested for presence or absence.
std::optional<T> is a library solution; it can either store a value of type T or std::nullopt if the value is missing.
Suppose we decide to go with the nullptr approach . In this case, let’s imagine that our domain model defines a Person who may or may not have an Address, which, in turn, can have ...