- 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.
- Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.
簡單的說,就是只要是base class可以使用的地方都能夠使用derived class代替。
但是反過來就不行了,子類別出現的地方,父類別不一定可以使用。
沒有留言:
張貼留言