Skip to content

Polymorphism through class extension

Motivation

Interfaces let many classes commit to the same contract, but they do not express the case where one class is a kind of another. Class extension lets a subclass inherit and refine its parent's contract rather than reimplementing it, with instances of the subclass usable wherever the parent is expected.