0% found this document useful (0 votes)
16 views31 pages

Technology Consulting - by Slidesgo

Uploaded by

Nandini Kasi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views31 pages

Technology Consulting - by Slidesgo

Uploaded by

Nandini Kasi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 31

UNIT

IV
INHERITANCE
TeamMate

LULUWA
LUBNA
Multilevel
Hybrid Inheritance
JUWERIYA Inheritance and and hierachial
Intro of multiple inheritance inheritance
inheritance and
single inheritance
INHERITANCE

MULTI-LEVEL HIERARICHIAL
INHERITANCE INHERITANCE

01 02 03 04

MULTIPLE HYBRID
INHERITANCE INHERITANCE
01
MULTI-LEVEL
INHERITANC
E
Syntax
MULTI-LEVEL
INHERITANCE
EXPLANATION

In the above program, there are two base


class A and B from which class C is inherited.
Therefore, derived class C inherits all the public members
of A and B and
retains their visibility. Here, we have created the
object obj1 of derived class C.
02
MULTIPLE
INHERITANCE
As shown in above block
diagram, class C is derived
from two base classes A and
B.
As in other inheritance,
based on the visibility mode
used or access specifier used
while deriving, the
properties of the base class
are derived. Access specifier
can be private, protected or
public.
Syntax
MULTIPLE
INHERITANCE
EXPLANATION

In the above program, there are two base class A and B from which
class C is inherited. Therefore, derived class C inherits all the public
members of A and B and retains their visibility. Here, we have
created
the object obj1 of derived class C.
How does multiple inheritance
differ from multilevel
inheritance?
Though but multiple and multilevel sounds like same but they
differ hugely in meaning. In multilevel inheritance, we have
multiple parent classes whereas in in multiple inheritance we
have multiple base classes.

To put it in simple words, in multilevel inheritance, a class is


derived from a class which is also derived from another base
class. And these levels of inheritance can be extended
On the contrary, in multiple inheritance, a class is
derived from two different base classes.
For example
• Multilevel inheritance : Inheritance of characters by
a child from father and father inheriting characters
from his father (grandfather)
• Multiple inheritance : Inheritance of characters by a
child from mother and father
03
HIERARICHIAL
INHERITANCE
As shown in above block diagram, in
C++ hierarchical inheritance all the
derived classes have common base
class. The base class includes all the
features that are common to derived
classes.
As in other inheritance, based on the
visibility mode used or access
specifier used while deriving, the
properties of the base class are
derived. Access specifier can be
private, protected or public.
Syntax
HIERARICHIAL
INHERITANCE
EXPLANATION

In this example, there is only one base class A from


which two class B and C are derived. Both derived
class have their own members as well as base class
members.
The product is calculated in the derived class B,
whereas, the sum is calculated
in the derived class C but both use the values
of x and y from the base class.
Output
04
HYBRID
INHERITANC
E
Above block diagram shows
the hybrid combination of
single inheritance and multiple
inheritance. Hybrid inheritance
is used in a situation where we
need to apply more than one
inheritance in a program.

As in other inheritance, based


on the visibility mode used or
access specifier used while
deriving, the properties of the
base class are derived. Access
specifier can be private,
protected or public.
Syntax
Hybrid Inheritance
EXPLANATION

As shown in block diagram class B is derived from


class A
which is single inheritance
and then Class D is inherited from B and
class C which is multiple inheritance.
So single inheritance and multiple inheritance jointly
results in hybrid inheritance.
C++
THANKING ALL MY TEAM MATE FOR
WONDERFUL SUPPORT

JUWERIYA RAFI

LULUWA
MOHAMMED

LUBNA ZAINAB
THANK
YOU

You might also like