Single Inheritance
In Single Inheritance one class extends another class (one class only).
Class B extends only Class A. Class A is a super class and Class B is a Sub-class.
CLASS A CLASS B
class A
{
…….. // Members of base class
};
class B : public A
{
…….. // Members of derived class
};
Single Inheritance is declared as follows
Multilevel Inheritance
In Multiple Inheritance, a class (Inter-mediate base class) is derived from
base class, which is again derived into some other class
The class A serves as a base class for the derived class B, which in turn serves as a base class for the
derived class C.
class A
{
……… //Members of base class
{;
class B : public A
{
……… //Members of derived class, B derived from A
};
class C : public B
………. //Members of derived class, C derived from B
};
CLASS A CLASS B CLASS C
Multilevel Inheritance is declared as follows
Multiple Inheritance
In Multiple Inheritance, a class is derived from more than one base classes.
class A
{
……… //Members of base class A
{;
class B
{
……… //Members of base class B
};
class C : public A, public B
{
………. //Members of derived class
};
CLASS A
CLASS A
CLASS A
BASE CLASSES
DERIVED CLASS
Multiple Inheritance is declared as follows
Hierarchical Inheritance
In Hierarchical Inheritance, one base class is inherited into two or more
Derived Classes
class A
{
……… //Members of base class A
{;
class B : public A
{
……… //Members of Derived class , B derived from A
};
class C : public A
{
………. //Members of derived class , C derived from A
};
CLASS C
CLASS A
CLASS B
CLASS A
BASE CLASS Hierarchical Inheritance is declared as follows
Hybrid Inheritance
In Hybrid Inheritance, more than one type of inheritances are used to derive a new Sub
Class.
class A class C : public A
{ {
……….. …………
……….. …………
}; };
class B : public A class D : public B, public C
{ {
………. …………
}; };
CLASS A
CLASS B CLASS C
CLASS D
INTERMEDIATE
B/W BASE
CLASSES
DERIVED CLASS
BASE CLASS
Hybrid Inheritance is declared as follows
ADVANTAGES OF INHERITANCE
 Reusability : Inheritance helps the code to be reused in many situations. The base class is
defines and once it is compiled, it need not be reworked. Using the concept of
Inheritance, the programmer can create as many derived classes from the base
class as needed while adding
Specific features to each derived class as needed
 Saves Time and Effort : The above concept of reusability achieved by inheritance saves the
programmer’s time and effort. Since the main code written can be reused
in various situations as needed.
Inheritance allows programmers to create classes that are built
upon existing classes, to specify a new implementation while
maintaining the same behaviors (realizing an interface), to reuse
code and to independently extend original software via public
classes and interfaces.

iheritence.pptx

  • 1.
    Single Inheritance In SingleInheritance one class extends another class (one class only). Class B extends only Class A. Class A is a super class and Class B is a Sub-class. CLASS A CLASS B class A { …….. // Members of base class }; class B : public A { …….. // Members of derived class }; Single Inheritance is declared as follows
  • 2.
    Multilevel Inheritance In MultipleInheritance, a class (Inter-mediate base class) is derived from base class, which is again derived into some other class The class A serves as a base class for the derived class B, which in turn serves as a base class for the derived class C. class A { ……… //Members of base class {; class B : public A { ……… //Members of derived class, B derived from A }; class C : public B ………. //Members of derived class, C derived from B }; CLASS A CLASS B CLASS C Multilevel Inheritance is declared as follows
  • 3.
    Multiple Inheritance In MultipleInheritance, a class is derived from more than one base classes. class A { ……… //Members of base class A {; class B { ……… //Members of base class B }; class C : public A, public B { ………. //Members of derived class }; CLASS A CLASS A CLASS A BASE CLASSES DERIVED CLASS Multiple Inheritance is declared as follows
  • 4.
    Hierarchical Inheritance In HierarchicalInheritance, one base class is inherited into two or more Derived Classes class A { ……… //Members of base class A {; class B : public A { ……… //Members of Derived class , B derived from A }; class C : public A { ………. //Members of derived class , C derived from A }; CLASS C CLASS A CLASS B CLASS A BASE CLASS Hierarchical Inheritance is declared as follows
  • 5.
    Hybrid Inheritance In HybridInheritance, more than one type of inheritances are used to derive a new Sub Class. class A class C : public A { { ……….. ………… ……….. ………… }; }; class B : public A class D : public B, public C { { ………. ………… }; }; CLASS A CLASS B CLASS C CLASS D INTERMEDIATE B/W BASE CLASSES DERIVED CLASS BASE CLASS Hybrid Inheritance is declared as follows
  • 6.
    ADVANTAGES OF INHERITANCE Reusability : Inheritance helps the code to be reused in many situations. The base class is defines and once it is compiled, it need not be reworked. Using the concept of Inheritance, the programmer can create as many derived classes from the base class as needed while adding Specific features to each derived class as needed  Saves Time and Effort : The above concept of reusability achieved by inheritance saves the programmer’s time and effort. Since the main code written can be reused in various situations as needed.
  • 7.
    Inheritance allows programmersto create classes that are built upon existing classes, to specify a new implementation while maintaining the same behaviors (realizing an interface), to reuse code and to independently extend original software via public classes and interfaces.