C++ determines data types automatically—an improvement over C, but this feature sometimes “gets in the way.” For example, suppose we want to print the address stored in a
char * pointer. The
<< operator has been overloaded to output a
char * as a null-terminated C-style string. To output the address, you can cast the
char * to a
void * (this can be done to any pointer variable). Figure 13.3 demonstrates printing a
char * variable in both string and address formats. The address prints here as a hexadecimal (base-16) number—in general, the way addresses print is implementation dependent. To learn more about hexadecimal numbers, see Appendix D. We say more about controlling the bases of numbers in Section 13.6.1 ...