4 ms·
The example for inheritence I liked best was something like this: Number (implementing trivial exponentiation through multiplication) RealNumber & ComplexNumb
by bjoernbu 15y ago
The example for inheritence I liked best was something like this:
Number (implementing trivial exponentiation through multiplication)
RealNumber & ComplexNumber implementing their specific kind of multiplication.
Later on replace the exponentiation by fast exponentiation. This directly demonstrates the benefits of avoiding code duplication.The change only has to be made in one place.