简体   繁体   中英

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'. 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 . 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 .

"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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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