What is inheritance hierarchy?

Started by chinmay.sahoo, 03-12-2016, 03:58:28

Previous topic - Next topic

chinmay.sahooTopic starter

Functionality derived from a class is called as a derived class. It can also be a based class for a different class. Thus it is possible to create a structure and this is called as inheritance hierarchy


RH-Calvin

#1
Inheritance is a fundamental concept in object-oriented programming (OOP) that allows for code reuse and the creation of hierarchical relationships between classes.

In OOP, a class can inherit properties (data variables) and methods (functions or behaviors) from another class, which is called the base or parent class. The class that inherits these properties and methods is called the derived or child class.

The inheritance hierarchy represents the relationship between classes in a hierarchical structure. In this hierarchy, subclasses or derived classes are placed below their superclass or base class. This hierarchy can be visualized as a tree-like structure, where the base class is at the top and derived classes branch out below it.

The derived class inherits all the public and protected properties and methods from the base class. It can then add new properties or methods or override the existing ones to customize its behavior or extend the functionality provided by the base class.

The inheritance hierarchy promotes code reuse, as common or shared functionalities can be defined in the base class and inherited by multiple derived classes. This simplifies the development process, improves code organization, and allows for easy maintenance and modifications.

Overall, inheritance and the inheritance hierarchy are powerful concepts in OOP that facilitate code reuse, modularity, and extensibility, making it easier to build complex software systems.

In object-oriented programming (OOP), inheritance is when an object or class is based on another object (prototypal inheritance) or class (class-based inheritance), using the same implementation (inheriting from an object or class) specifying implementation to maintain the same behavior.


TomClarke

Inheritance has some benefits:
- subclasses provide specialized behaviors from the basis of common elements provided by the superclass. Through the use of inheritance, programmers can reuse the code in the superclass many times;
- programmers can implement superclasses called abstract classes that  define "generic"  behaviors. The abstract superclass defines and may partially implement the behavior but much of the class is undefined and unimplemented. Other programmers fill in the details with specialized subclasses.