文件名称:里氏代换原则-java高级 面向对象
文件大小:1.88MB
文件格式:PPT
更新时间:2024-05-16 03:14:27
13 21
里氏代换原则 里氏代换原则定义 里氏代换原则:如果对每一个类型为S的对象o1,都有类型为T的对象o2,使得以T定义的所有程序P在所有的对象o1都代换o2时,程序P的行为没有变化,那么类型S是类型T的子类型。 Liskov Substitution Principle (LSP): If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when o1 is substituted for o2 then S is a subtype of T. 里氏代换原则:所有引用基类的地方必须能透明地使用其子类的对象。 Liskov Substitution Principle (LSP): Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.