Inheritance in C++
OWAIS RAZA
NSU2103088
Content
• What is Inheritance?
• Types of Inheritance
• Single Inheritance
• Multiple Inheritance
• Multilevel Inheritance
• Hierarchical Inheritanc
• Hybrid Inheritance
Inheritance
T h e c a p a b i l i t y o f a c l a s s t o d e r i ve p ro p e r ti e s a n d c h a ra c t e r i sti c s f ro m
a n o t h e r c l a s s i s c a l l e d I n h e r i ta n c e . I n h e r i ta n c e i s o n e o f t h e m o s t
i m p o r ta nt fe at u re s o f O b j e c t- O r i e nt e d P ro g ra m m i n g .
I n h e r i ta n c e i s a fe at u re o r a p ro c e s s i n w h i c h , n e w c l a s s e s a re c re at e d
f ro m t h e ex i s ti n g c l a s s e s . T h e n e w c l a s s c re a t e d i s c a l l e d “d e r i ve d c l a s s ”
o r “c h i l d c l a s s ” a n d t h e ex i sti n g c l a s s i s k n o w n a s t h e “ b a s e c l a s s ” o r
“ p a re nt c l a s s ”. T h e d e r i ve d c l a s s n o w i s s a i d t o b e i n h e r i t e d f ro m t h e b a s e
class.
• Types
SingleofInheritance
Inheritance
• Multiple Inheritance
• Multilevel Inheritance
• Hierarchical
Inheritance
• Hybrid Inheritance
SINGLE INHERITANCE
Single inheritance 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
Multiple inheritance is the process of
deriving a new class that inherits the
attributes from two or more classes.
Where 'A and B' is the base class, and
'C' is the derived class.
MULTILEVEL INHERITANCE
Multilevel inheritance is a process of deriving
a class from another derived class.
HIERARCHICAL INHERITANCE
Hierarchical inheritance is defined as the
process of deriving more than one class from a
base class.
HYBRID INHERITANCE
Hybrid inheritance is a combination
of more than one type of inheritance.
Thank You