Inheritance (object-oriented programming)
This article has multiple issues. Please help or discuss these issues on the(
An inherited class is called a subclass of its parent class or super class. The term "inheritance" is loosely used for both class-based and prototype-based programming, but in narrow use the term is reserved for class-based programming (one class inherits from another), with the corresponding technique in prototype-based programming being instead called
Inheritance should not be confused with
Inheritance is contrasted with
There are various types of inheritance, based on paradigm and specific language.
where subclasses inherit the features of one superclass. A class acquires the properties of another class.
where one class can have more than one superclass and inherit features from all parent classes.
"Multiple Inheritance (object-oriented programming) was widely supposed to be very difficult to implement efficiently. For example, in a summary of
C++in his book on objective CBrd.Cox actually claimed that adding Multiple inheritance to C++ was impossible. Thus, multiple inheritance seemed more of a challenge. Since I had considered multiple inheritance as early as 1982 and found a simple and efficient implementation technique in 1984. I couldn't resist the challenge. I suspect this to be the only case in which fashion affected the sequence of events."
In JDK 1.8, Java now has support for multiple inheritance.
where a subclass is inherited from another subclass. It is not uncommon that a class is derived from another derived class as shown in the figure "Multilevel inheritance".
The class A serves as a base class for the derived class B, which in turn serves as a base class for the derived class C. The class B is known as intermediate base class because it provides a link for the inheritance between A and C. The chain ABC is known as inheritance path.
A derived class with multilevel inheritance is declared as follows:
Class A(...); //Base class Class B : public A(...); //B derived from A Class C : public B(...); //C derived from B
This process can be extended to any number of levels.
where one class serves as a superclass (base class) for more than one sub class.
a mix of two or more of the above types of inheritance.