July 2013
Intermediate to advanced
144 pages
4h 50m
English
Consider the following numeric types from earlier chapters:
• Complex
• Rational
• Money
• Mass
• Days
• Date
• Voltage
• Current
• Resistance
• Power
Which ones lend themselves to specialization, that is, to being used as a base class for one or more specialized derived types?
The surprising—and to some, disappointing—answer is that none of them do. Even though some aspects of object orientation are well suited to elementary data types, inheritance and polymorphism are less useful with elementary objects than with composite or container objects.
Suppose someone proposes this inheritance hierarchy:
Or this: ...
Read now
Unlock full access