Inheritance
-
Upload
ashish-awasthi -
Category
Technology
-
view
6.293 -
download
0
Transcript of Inheritance
C++C++InheritanceInheritance
BY- Ashish Awasthi
IntroductionIntroduction►The capability of one class to inherit The capability of one class to inherit
properties from another class is called properties from another class is called INHERITANCE. INHERITANCE. This is the property of This is the property of OBJECT ORIENTED PROGRAMMING, OBJECT ORIENTED PROGRAMMING, which derives new classes (called which derives new classes (called derived classes) from old ones. With derived classes) from old ones. With the derived class inheriting the the derived class inheriting the properties, including the method of properties, including the method of the old class is known as base class. the old class is known as base class.
Concept of INHERITANCE Concept of INHERITANCE
Base class
Property A
Property BProperty C
Derived From
Derived class
Property DProperty AProperty B Property C
Defined in Derived Class
Defined in Base Class But accessible from Derived Class
Levels of INHERITANCELevels of INHERITANCE►(A)- Single Inheritance.(A)- Single Inheritance.►(B)- Multilevel Inheritance.(B)- Multilevel Inheritance.►(C)- Multiple Inheritance.(C)- Multiple Inheritance.►(D)- Hierarchical Inheritance.(D)- Hierarchical Inheritance.►(E)- Hybrid Inheritance.(E)- Hybrid Inheritance.
Single InheritanceSingle Inheritance• In this INHERITANCE have only one Base class and one Derived class.
BASE CLASS
DERIVED CLASS
Multilevel InheritanceMultilevel Inheritance• In this INHERITANCE we have a chain of all classes and one BASE LINE , In this we must have to use three classes, there is one Base class and more than one Derived classes.
BASE CLASS
DERIVED CLASSES
Class A
Class B
Class C
Multiple InheritanceMultiple Inheritance•In this INHERITANCE we have more than one independent Base classes and one Derived class, connected with all Base classes.
BASE CLASSES
DERIVED CLASS
Class A Class B
Class C
Hierarchical InheritanceHierarchical Inheritance•This INHERITANCE is just opposite of Multiple inheritance.
Class A
Class B Class C
BASE CLASS
DERIVED CLASES
Hybrid InheritanceHybrid Inheritance•This is a combine form of Multiple and Hierarchical Inheritance.
Class B Class C
Class D
Class A
Derived Base class
BASE CLASS
DERIVED CLASS