1815 and 1859 Inheritance in C++

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 10

INHERITANCE IN C++

1815 – YASH THAKUR


1859 – VINAY GUPTA
What is an inheritance?

 Inheritance is the process by which new classes called derived classes are created from
existing classes called base classes.
 The derived classes have all the features of the base class and the programmer can choose
to add new features specific to the newly created derived class.
 The idea of inheritance implements the is a relationship. For example, mammal IS-A
animal, dog IS-A mammal hence dog IS-A animal as well and so on.
FEATURES/ADVANTAGES OF
INHERITANCE

 Reusability of code.
 Saves time and effort.
 Faster development, easier maintenance and easy to extend.
 Capable of expressing the inheritance relationship and its transitive nature which ensures
closeness with real world problems.
DISADVANTAGES OF INHERITANCE

 Inherited functions work slower than normal function as there is indirection.


 Improper use of inheritance may lead to wrong solutions.
 Often, data members in the base class are left unused which may lead to memory wastage.
 Inheritance increases the coupling between base class and derived class.
APPLICATIONS OF INHERITANCE

 The main purpose of introducing the inheritance is to “REUSE” your code and in the
same way , when you reuse your code it means directly you OPTIMIZE your code and it
will reduce your redundancy of your code.
 Inheritance is one of the fundamental features of object-oriented programming.
The types of inheritance in c++

1)Single inheritance.
2)Multiple inheritance.
3)Multilevel inheritance.
4)Hierarchical inheritance.
5)Hybrid inheritance.
 Single inheritance : It is defined as the inheritance in which a derived class is inherited
from the only one base class. where ‘A’ is the base class, and ‘B’ is the derived class.
 Multiple inheritance : It is a feature of c ++ where a class can inherit from more than
one classes.
 Multilevel inheritance : If a class is derived from another derived class then it is called
multilevel inheritance. So in c++ multilevel inheritance , a class has more than one parent
class.
 Hierarchical inheritance: When several classes are derived from common base class it is
called hierarchical inheritance. In c++ hierarchical inheritance , the feature of the base
class is inherited onto more than one sub class.
 Hybrid inheritance: The inheritance in which the derivation of a class involves more
than one form of any inheritance is called hybrid inheritance. Basically in c++ hybrid
inheritance is combination of two or more types of inheritance. It can also be called multi
path inheritance.

You might also like