开发者

OOP Difference between a derived class and an inherited class?

From an OOP point of view is there any difference between a derived class and an inhe开发者_开发问答rited class? Or is it simply terminology?


When using inheritance, the inherited class is called the base class, and the inheriting class is called the derived class.


The term derived class is preferred C++ parlance for a class that inherits from another class, which in C++ parlance is called a base class. So in C++ the terms you ask about are identical.


Neil's answer confused me a bit, and so I checked some public sources.

Consider a Base Class and a Sub Class (SubClass extends BaseClass in Java terminology), than

  • the Sub Class derives Base Class (Sub Class is a derived class of Base Class) and
  • the Sub Class inherits from Base Class (Base Class is a/the inherited class of Sub Class)

So in my opinion both terms define the same relationship between to classes but from different perspectives.


Inheritance terminology by Bertran Meyer (Object-Oriented Software Construction, p.464):

Basic conventions and terminology

The following terms will be useful in addition to “heir” and “parent”.

A descendant of a class C is any class that inherits directly or indirectly from C, including C itself. (Formally: either C or, recursively, a descendant of an heir of C.) An ancestor of C is a class A such that C is a descendant of A.

In the literature you will also encounter the terms “subclass” and “superclass”, but we will stay away from them because they are ambiguous; sometimes “subclass” means heir (immediate descendant), sometimes it is used in the more general sense of proper descendant, and it is not always clear which. In addition, we will see that the “subset” connotation of this word is not always justified.


maybe interesting, if you override a method, in Delphi you write:

inherited; // so "inherited" is the base class

instead of

base.BaseImplementation(); // C#
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜