I was reading "The C++ Programming Language" by Bjarne Stroustrup to learn C++ and encountered with the following passage:
The
static_cast
operator converts between related types such as one pointer type to another in the same class hierarchy, an integral type to an enumeration, or a floating-point type to an integral type. Thereinterpret_case
handles conversions between unrelated types such as an integer to a pointer or a pointer to an unrelated pointer type.
To me, it is not clear what determines any two given types be related or unrelated and the examples mentioned seem not that exhaustive.
Stroustrup says that types are classified into 1. Arithmetic types 2. User-defined types and 3. Built-in types, and from the examples above, he regards arithmetic type (int) to be related to a user-defined type (enum). A float type to an int is obvious because they both are arithmetic types.
However, he classifies two pointers, which should be both built-in types according to his definition, to be unrelated.
So what do we exactly mean by saying "two types are related (unrelated)"?