Why are Super-class and Sub-class reversed?

后端 未结 7 2306
滥情空心
滥情空心 2021-02-12 12:29

In set theory, a set is a superset if it contains everything in the original set and possibly more. A subset however is does not contain everything of the initial set.

W

7条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-12 13:11

    Yes, but if you think of your diagram as a topographic map, the subclasses have higher altitudes than the superclass. Hence the confusion.

    Another way of looking at this is that the superclass is akin to the leading digit in a number (to make this a programming language friendly analogy, we'll say a floating point number). As the number acquires more digits, each new digit "inherits" all the digits that precede it. Similarly, as the subclass gains more methods, it inherits the list of superclasses, in the order in which they were named, that precede it.

    Hope this helps.

提交回复
热议问题