简体   繁体   English

OOP中“祖先”的对立面

[英]Opposite of 'Ancestor' in OOP

I am looking for the best term to use to describe a child that inherits an ancestor. 我正在寻找用于描述继承祖先的孩子的最佳术语。

For example, a 'Car' object may derive from its ancestor 'Vehicle'. 例如,'Car'对象可以从其祖先'Vehicle'派生。 However, is there a better/more suitable word to use than derivative for the inverse? 但是,是否有一个更好/更合适的词使用而不是导数的逆?

Ancestor/Descendant are a more common pairing when there can be intermediate layers between the items under discussion. 当讨论中的项目之间存在中间层时,祖先/后代是更常见的配对。

Eg if we have Vehicle -> Wheeled Vehicle -> Car (and assuming other possible classes also exist), both Vehicle and Wheeled Vehicle are ancestors of Car and both Wheeled Vehicle and Car are descendants of Vehicle . 例如,如果我们有Vehicle - > Wheeled Vehicle - > Car (假设其他可能的类别也存在),无论是VehicleWheeled Vehicle是祖先Car和两个Wheeled VehicleCar都是后人Vehicle We would describe Vehicle as the parent of Wheeled Vehicle and Car as a child of Wheeled Vehicle but we wouldn't generally use parent or child to describe the relationship between Vehicle and Car . 我们将描述Vehicle作为母公司 Wheeled VehicleCar作为一个孩子Wheeled Vehicle ,但我们一般不会用父母或子女来描述之间的关系VehicleCar

"Inherited class" and "derived class" work well. “继承类”和“派生类”运行良好。 At times instances of objects have parent/child relationships that have nothing to do with inheritance, like parent nodes and child nodes. 有时,对象的实例具有与继承无关的父/子关系,如父节点和子节点。 In those cases referring to "parent" and "child" classes in the same context could be confusing. 在那些情况下,在同一上下文中引用“父”和“子”类可能会令人困惑。

Also, using the parent/child metaphor, every child is a parent, not every parent is a child, and some classes are infertile (sealed.) 此外,使用父/子比喻,每个孩子都是父母,而不是每个父母都是孩子,有些班级是不育的(密封)。

Parent and child 父母和孩子

So a car derives from it's parent vehicle; 所以汽车来自它的母车; and a vehicle has multiple children such as car, boat and plane. 车辆有多个孩子,如汽车,船和飞机。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM