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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access