What are the advantages of Inheritance in C++? tccicomputercoaching.com
- June 29, 2019
- Posted by: Riddhi Dhandha
- Category: C++ Programming Langauge at TCCI
Inheritance is mechanism to build a new class from existing one.
Advantage of Inheritance:
One of the key benefits of inheritance is to minimize the amount of duplicate code in an application by sharing common code amongst several subclasses, where equivalent code exists in two related classes. This also tends to result in a better organization of code and smaller, simpler compilation units.
Inheritance can also make application code more flexible to change because classes that inherit from a common super class can be used interchangeably.
Reusability-> facility to use public methods of base class without rewriting the same.
Extensibility-> extending the base class logic as per business logic of the derived class
Data hiding-> base class can decide to keep some data private so that it cannot be altered by the derived class
Overriding-> With inheritance, we will be able to override the methods of the base class so that meaningful implementation of the base class method can be designed in the derived class.
For more information about Inheritance in C++.
Call us @ 9825618292
Visit us @ www.tccicomputercoaching.com