What does Liskov Substitution Principle preserve? [duplicate]
问题 This question already has answers here : What is an example of the Liskov Substitution Principle? (29 answers) Closed 7 months ago . As I've read the substitution of objects of a concrete type by instances of a subclass of that concrete type must preserve a program's correctness, a program's invariants. I'd like to know what exactly is meant by correctness and invariants of a program? 回答1: Let's say you have a class Animal and someone asks you what it's supposed to do, what it can be used for