INHERITANCE

Definition:

 

In object-oriented programming (OOP), inheritance is when an object or class is based on another object or class, using the same implementation (inheriting from a class) specifying implementation to maintain the same behavior (realizing an interface; inheriting behavior). It is a mechanism for code reuse and to allow independent extensions of the original software via public classes and interfaces. The relationships of objects or classes through inheritance give rise to a hierarchy. Inheritance was invented in 1967 for Simula.

Inheritance is a method by which new classes are created or derived from the existing classes. Using Inheritance some qualities of the base classes are added to the newly derived class, apart from its own features The advantage of using "Inheritance" is due to the reusability of classes in multiple derived classes. The ":" operator is used for inherting a class.Inheritance is the capability of one class to acquire properties and characteristics from another class. The class whose properties are inherited by other class is called the Parent or Base or Super class. And, the class which inherits properties of other class is called Child or Derived or Sub class.

 

Basic Syntax of Inheritance:

 

class Subclass_name : access_mode Superclass_name

While defining a subclass like this, the super class must be already defined or atleast declared before the subclass declaration.

Access Mode is used to specify, the mode in which the properties of superclass will be inherited into subclass, public, privtate or protected.

Super Class and Sub Class:

Subclass, "derived class", heir class, or child class is a modular, derivative class that inherits one or more language entities from one or more other classes (called superclasses, base classes, or parent classes). The semantics of class inheritance vary from language to language, but commonly the subclass automatically inherits the instance variables and member functions of its superclasses.

 

 

 

 

Inheritance and its types - by Mrs.M.Sharmila and Mrs.R.Jaya Bharathi