Solution (source code)

= Solution

<Class inheritance> defines a <software class> by extending another <software class>, inheriting its available operations and optionally adding members or providing <method overriding>. In languages supporting it, <traits> and <mixins> can contribute reusable behavior as well.

\b[Use inheritance for a sound specialization whose instances can satisfy the superclass's contract wherever its instances are expected.] For example, every specific gate in part (d) is usable through the common gate <object interface>. <Subtyping> supports this substitution and <dynamic dispatch> selects the specialized calculation. Merely noticing shared code does not establish the required behavioral relationship; <object composition> is often better for a replaceable component or policy that an object contains. A subclass must preserve the superclass's promised behavior, rather than just sharing its field names.