Friday, 31 January 2020

Inheritance

0 comments

Inheritance


? Inheritance is the capability of one class to inherit properties from another class.
? It supports reusability of code and is able to simulate the transitive nature of real life
objects. Inheritance has many forms: Single inheritance, multiple inheritance, hierarchical
inheritance, multilevel inheritance and hybrid inheritance.
? A subclass can derive itself publicly, privately or protectedly. The derived class constructor
is responsible for invoking the base class constructor, the derived class can directly access
only the public and protected members of the base class.
? When a class inherits from more than one base class, this is called multiple inheritance.
? A class may contain objects of another class inside it.
? his situation is called nesting of objects and in such a situation, the contained objects are
constructed first before constructing the objects of the enclosing class.
? Single Inheritance: Where a class inherits from a single base class, it is known as single
inheritance.
? Multilevel Inheritance: When the inheritance is such that the class. A serves as a base class
for a derived class B which is turn serves as a base class for the derived class C. This type
of inheritance is called ‘Multilevel Inheritance.’
Object-oriented Programming
Notes ? Multiple Inheritance: A class inherit the attributes of two or more classes. This mechanism
is known as Multiple Inheritance.’
? Hybrid Inheritance: The combination of one or more types of the inheritance.


Abstract Class: A class serving only a base class for other classes and no objects of which are
created.
Base class: A class from which another class inherits. (Also called super class)
Containership: The relationship of two classes such that the objects of a class are enclosed within
the other class.
Derived class: A class inheriting properties from another class. (also called sub class)
Inheritance: Capability of one class to inherit properties from another class.
Inheritance Graph: The chain depicting relationship between a base class and derived class.
Visibility Mode: The public, private or protected specified that controls the visibility and
availability of a member in a class.

No comments:

Post a comment