Type Conversions
C++’s profusion of types lets you match the type to the need. It also complicates life for the computer. For example, adding two short
values may involve different hardware instructions than adding two long
values. With 11 integer types and 3 floating-point types, the computer can have a lot of different cases to handle, especially if you start mixing types. To help deal with this potential mishmash, C++ makes many type conversions automatically:
• C++ converts values when you assign a value of one arithmetic type to a variable of another arithmetic type.
• C++ converts values when you combine mixed types in expressions.
• C++ converts values when you pass arguments to functions.
If you don’t understand what happens in these ...
Get C++ Primer Plus 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.