Chapter 19. Casts

CastThe form in which something is made or constructed.

Implicit Conversion

On our behalf, the C++ compiler will carry out a multitude of implicit conversions between types. Just because they're implicit, however, doesn't mean that they're trivial. Conversions between integral and floating-point types can involve significant work [Meye1996, Stro1997]; conversion between integral types of difference sizes can involve truncation or sign extension [Stro1997]; conversions between pointer types of virtually derived classes on an implementing instance involve pointer adjustment [Lipp1996]. The problems, from the point of view of accuracy, of conversions were mentioned in Chapter 13, and are described in detail in [Stro1997]. In this ...

Get Imperfect C++ Practical Solutions for Real-Life Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.