The Liskov Substitution Principle requires every subclass object to replace its superclass object without causing logic or runtime errors. Different but meaningful results remain acceptable. section 7.2
Apply the principle by checking that:
- The subclass genuinely fits the superclass’s is-a relationship. section 7.2
- Overriding functions preserve compatible preconditions and postconditions. section 7.0 section 7.6
- Substitution does not expose operations that contradict the superclass abstraction. section 7.2
CircularBuffer and vector
Making CircularBuffer a vector subclass exposes at() and erase(), allowing clients to modify or remove elements in ways that violate circular-buffer behavior and eventually cause an exception. Refactoring CircularBuffer to contain an aggregated vector preserves the buffer interface and prevents those invalid substitutions. section 7.2 section 7.6




