Why are Super-class and Sub-class reversed?

2019-03-23 22:31发布

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.

With that in mind, in most object-oriented programming languages (I'm thinking Objective-C but I know the same is true for Java and others), the parent class is called the super class, and any class which inherits from the super is called a subclass.

Isn't this backwards? A subclass inherits things like all instance variables and methods from its superclass, thus it "contains" everything from the parent, plus whatever is added in the subclass. Is this just a naming mistake or was this intentional, and if so why?

7条回答
Viruses.
2楼-- · 2019-03-23 23:08

I sidestep the whole super/sub class issue and refer to them as "derived" and "parent" class.

查看更多
登录 后发表回答