A Simple Example of a Class Design Reuse

The strong typing approach of C++ allows the compiler to spot programming errors when the programmer uses one type instead of another. C++ allows a number of exceptions to this rule. Numeric values can be used interchangeably. Programmer-defined types can be used instead of other types provided that conversion constructors and conversion operators are available. Classes related through inheritance also allow limited substitution.

Still, many limitations on the use of typed values remain. Many algorithms are essentially the same regardless of the type of values they operate on. For example, searching for a given account in the array of account objects requires going through each component of the array ...

Get Core C++ A Software Engineering Approach 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.