SlideShare a Scribd company logo
1 of 13
Polymorphism
Topics:
1. What is Polymorphism?
2. What is Polymorphism in OOP?
3. How Polymorphism can be achieved?
4. Types of Polymorphism
5. Function Overloading
6. Function Overriding
7. Early Binding
8. Late Binding and Virtual function
9. Pure Virtual Function
What is Polymorphism?
The process of representing one form in multiple form in known as
polymorphism . Typically, polymorphism occurs when there is a
hierarchy of classes and they are related by inheritance.
It means that a call to a member function will cause a different
function to be executed depending on the type of object that
invokes the function.
What is Polymorphism in OOP?
After the inheritance it is another most important feature
of OOP.
In polymorphism, the member functions with same name are
define in base class and also in each derived class.
Polymorphism is used to keep the interface of base class to
its derived classes.
Polymorphism can be achieved by mean of virtual functions.
In polymorphism one pointer to a base class object may also
point any object of its derived class.
How Polymorphism can be achieved:
Polymorphism can be achieved in Three ways:
1. Function Overloading
2. Function Overriding
3. Dynamic Binding.
Types of Polymorphism:
Fig: Types of polymorphism
Polymorphism
Static Polymorphism :
Compile time/
static/Early Binding
Dynamic Polymorphism:
Runtime/Dynamic/Late
Binding
Types of Polymorphism:
Static Polymorphism: It takes place during Compile
time. Function Overloading, Operator Overloading
implements static polymorphism.
Dynamic Polymorphism: It takes place during Run
time. The member function whice change Their
behavior during run time called Virtual Functions.
Function Overloading
Here we have multiple definitions for the same function name in the same scope. The
definition of the function must differ from each other by the types and/or the numberof
arguments in the argument list.
Function Overriding
Overriding of functions happens when one class inherits another class. Here functions of both
class have the same name and there world be same parameter list and return type of the
functions should be same.
Early Binding
Events occurring at compile time are known as early binding. In the process of early binding
all info which is required for a function call is known at compile time. Examples of early
binding: function calls, overloaded function calls, and overloaded operators.
Late Binding and Virtual Function:
All the Code is understood at the Time of Execution This is called as Late Binding. As we
Know that Late Binding is Performed By using the virtual Functions. Virtual Means Function
must be Override. Virtual Function is a function in base class, which is overrided in the
derived class, and which tells the compiler to perform Late Binding on this function.
Pure Virtual Function
The virtual function that is only declare But Not Define In The InThe
Base Class.
General Syntax:
virtual function_name()=0;
The class that contains the pure virtual function exists only to act as
base or parent classes.
Polymorphism

More Related Content

What's hot

Pure virtual function and abstract class
Pure virtual function and abstract classPure virtual function and abstract class
Pure virtual function and abstract classAmit Trivedi
Β 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programmingAmar Jukuntla
Β 
Pointers and call by value, reference, address in C
Pointers and call by value, reference, address in CPointers and call by value, reference, address in C
Pointers and call by value, reference, address in CSyed Mustafa
Β 
Polymorphism in Java by Animesh Sarkar
Polymorphism in Java by Animesh SarkarPolymorphism in Java by Animesh Sarkar
Polymorphism in Java by Animesh SarkarAnimesh Sarkar
Β 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingMd. Tanvir Hossain
Β 
Polymorphism
PolymorphismPolymorphism
PolymorphismArif Ansari
Β 
Object Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) IntroductionObject Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) IntroductionSamuelAnsong6
Β 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented ProgrammingIqra khalil
Β 
JDK,JRE,JVM
JDK,JRE,JVMJDK,JRE,JVM
JDK,JRE,JVMCognizant
Β 
Control structures in C++ Programming Language
Control structures in C++ Programming LanguageControl structures in C++ Programming Language
Control structures in C++ Programming LanguageAhmad Idrees
Β 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPSRonak Chhajed
Β 
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for BeginnersVineet Kumar Saini
Β 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)harsh kothari
Β 

What's hot (20)

polymorphism
polymorphism polymorphism
polymorphism
Β 
Java interfaces
Java   interfacesJava   interfaces
Java interfaces
Β 
Pure virtual function and abstract class
Pure virtual function and abstract classPure virtual function and abstract class
Pure virtual function and abstract class
Β 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programming
Β 
Pointers and call by value, reference, address in C
Pointers and call by value, reference, address in CPointers and call by value, reference, address in C
Pointers and call by value, reference, address in C
Β 
Polymorphism in Java by Animesh Sarkar
Polymorphism in Java by Animesh SarkarPolymorphism in Java by Animesh Sarkar
Polymorphism in Java by Animesh Sarkar
Β 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
Β 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Β 
Object Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) IntroductionObject Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) Introduction
Β 
Control statements in java
Control statements in javaControl statements in java
Control statements in java
Β 
Interface in java
Interface in javaInterface in java
Interface in java
Β 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
Β 
Functions in C++
Functions in C++Functions in C++
Functions in C++
Β 
JDK,JRE,JVM
JDK,JRE,JVMJDK,JRE,JVM
JDK,JRE,JVM
Β 
Control structures in C++ Programming Language
Control structures in C++ Programming LanguageControl structures in C++ Programming Language
Control structures in C++ Programming Language
Β 
Inheritance
InheritanceInheritance
Inheritance
Β 
Hill climbing algorithm
Hill climbing algorithmHill climbing algorithm
Hill climbing algorithm
Β 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
Β 
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
Β 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
Β 

Similar to Polymorphism

polymorphism-17013114666666666653806.pdf
polymorphism-17013114666666666653806.pdfpolymorphism-17013114666666666653806.pdf
polymorphism-17013114666666666653806.pdfkashafishfaq21
Β 
polymorphism OOP.pptx
polymorphism OOP.pptxpolymorphism OOP.pptx
polymorphism OOP.pptxAssadLeo1
Β 
polymorphism and virtual function
polymorphism and virtual functionpolymorphism and virtual function
polymorphism and virtual functionBhanuprataparya
Β 
polymorphism.pdf
polymorphism.pdfpolymorphism.pdf
polymorphism.pdfriyawagh2
Β 
Learn C# Programming Polymorphism & Operator Overloading
Learn C# Programming Polymorphism & Operator OverloadingLearn C# Programming Polymorphism & Operator Overloading
Learn C# Programming Polymorphism & Operator OverloadingEng Teong Cheah
Β 
Pocket java
Pocket javaPocket java
Pocket javaKumaran K
Β 
full defination of final opp.pptx
full defination of final opp.pptxfull defination of final opp.pptx
full defination of final opp.pptxrayanbabur
Β 
Dynamic Polymorphism in C++
Dynamic Polymorphism in C++Dynamic Polymorphism in C++
Dynamic Polymorphism in C++Dharmisha Sharma
Β 
What is java polymorphism and its types in java training?
What is  java polymorphism and its types in java training?What is  java polymorphism and its types in java training?
What is java polymorphism and its types in java training?kritikumar16
Β 
Polymorphism in C++
Polymorphism in C++Polymorphism in C++
Polymorphism in C++Rabin BK
Β 
C++ concept of Polymorphism
C++ concept of  PolymorphismC++ concept of  Polymorphism
C++ concept of Polymorphismkiran Patel
Β 
OOPS & C++(UNIT 4)
OOPS & C++(UNIT 4)OOPS & C++(UNIT 4)
OOPS & C++(UNIT 4)SURBHI SAROHA
Β 
1669617800196.pdf
1669617800196.pdf1669617800196.pdf
1669617800196.pdfvenud11
Β 
Paca oops slid
Paca oops slidPaca oops slid
Paca oops slidpacatarpit
Β 
oopsinvb-191021101327.pdf
oopsinvb-191021101327.pdfoopsinvb-191021101327.pdf
oopsinvb-191021101327.pdfJP Chicano
Β 

Similar to Polymorphism (20)

polymorphism-17013114666666666653806.pdf
polymorphism-17013114666666666653806.pdfpolymorphism-17013114666666666653806.pdf
polymorphism-17013114666666666653806.pdf
Β 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Β 
polymorphism OOP.pptx
polymorphism OOP.pptxpolymorphism OOP.pptx
polymorphism OOP.pptx
Β 
polymorphism and virtual function
polymorphism and virtual functionpolymorphism and virtual function
polymorphism and virtual function
Β 
polymorphism.pdf
polymorphism.pdfpolymorphism.pdf
polymorphism.pdf
Β 
Oop lecture 06
Oop lecture 06Oop lecture 06
Oop lecture 06
Β 
Java Basics
Java BasicsJava Basics
Java Basics
Β 
Learn C# Programming Polymorphism & Operator Overloading
Learn C# Programming Polymorphism & Operator OverloadingLearn C# Programming Polymorphism & Operator Overloading
Learn C# Programming Polymorphism & Operator Overloading
Β 
Pocket java
Pocket javaPocket java
Pocket java
Β 
full defination of final opp.pptx
full defination of final opp.pptxfull defination of final opp.pptx
full defination of final opp.pptx
Β 
Dynamic Polymorphism in C++
Dynamic Polymorphism in C++Dynamic Polymorphism in C++
Dynamic Polymorphism in C++
Β 
What is java polymorphism and its types in java training?
What is  java polymorphism and its types in java training?What is  java polymorphism and its types in java training?
What is java polymorphism and its types in java training?
Β 
Polymorphism in C++
Polymorphism in C++Polymorphism in C++
Polymorphism in C++
Β 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Β 
C++ concept of Polymorphism
C++ concept of  PolymorphismC++ concept of  Polymorphism
C++ concept of Polymorphism
Β 
OOPS & C++(UNIT 4)
OOPS & C++(UNIT 4)OOPS & C++(UNIT 4)
OOPS & C++(UNIT 4)
Β 
1669617800196.pdf
1669617800196.pdf1669617800196.pdf
1669617800196.pdf
Β 
Paca oops slid
Paca oops slidPaca oops slid
Paca oops slid
Β 
oopsinvb-191021101327.pdf
oopsinvb-191021101327.pdfoopsinvb-191021101327.pdf
oopsinvb-191021101327.pdf
Β 
Oops in vb
Oops in vbOops in vb
Oops in vb
Β 

More from zindadili

Namespaces
NamespacesNamespaces
Namespaceszindadili
Β 
Namespace1
Namespace1Namespace1
Namespace1zindadili
Β 
Exception handling
Exception handlingException handling
Exception handlingzindadili
Β 
Exception handling
Exception handlingException handling
Exception handlingzindadili
Β 
Templates2
Templates2Templates2
Templates2zindadili
Β 
Templates1
Templates1Templates1
Templates1zindadili
Β 
Virtual function
Virtual functionVirtual function
Virtual functionzindadili
Β 
Operator overloaing
Operator overloaingOperator overloaing
Operator overloaingzindadili
Β 
Operator overloading2
Operator overloading2Operator overloading2
Operator overloading2zindadili
Β 
Function overloading
Function overloadingFunction overloading
Function overloadingzindadili
Β 
Aggregation
AggregationAggregation
Aggregationzindadili
Β 
Hierarchical inheritance
Hierarchical inheritanceHierarchical inheritance
Hierarchical inheritancezindadili
Β 
Hybrid inheritance
Hybrid inheritanceHybrid inheritance
Hybrid inheritancezindadili
Β 
Multiple inheritance
Multiple inheritanceMultiple inheritance
Multiple inheritancezindadili
Β 
Abstraction1
Abstraction1Abstraction1
Abstraction1zindadili
Β 
Abstraction
AbstractionAbstraction
Abstractionzindadili
Β 
Access specifier
Access specifierAccess specifier
Access specifierzindadili
Β 
Inheritance
InheritanceInheritance
Inheritancezindadili
Β 
Friend function
Friend functionFriend function
Friend functionzindadili
Β 

More from zindadili (20)

Namespaces
NamespacesNamespaces
Namespaces
Β 
Namespace1
Namespace1Namespace1
Namespace1
Β 
Exception handling
Exception handlingException handling
Exception handling
Β 
Exception handling
Exception handlingException handling
Exception handling
Β 
Templates2
Templates2Templates2
Templates2
Β 
Templates1
Templates1Templates1
Templates1
Β 
Virtual function
Virtual functionVirtual function
Virtual function
Β 
Operator overloaing
Operator overloaingOperator overloaing
Operator overloaing
Β 
Operator overloading2
Operator overloading2Operator overloading2
Operator overloading2
Β 
Function overloading
Function overloadingFunction overloading
Function overloading
Β 
Aggregation
AggregationAggregation
Aggregation
Β 
Hierarchical inheritance
Hierarchical inheritanceHierarchical inheritance
Hierarchical inheritance
Β 
Hybrid inheritance
Hybrid inheritanceHybrid inheritance
Hybrid inheritance
Β 
Multiple inheritance
Multiple inheritanceMultiple inheritance
Multiple inheritance
Β 
Abstraction1
Abstraction1Abstraction1
Abstraction1
Β 
Abstraction
AbstractionAbstraction
Abstraction
Β 
Access specifier
Access specifierAccess specifier
Access specifier
Β 
Inheritance
InheritanceInheritance
Inheritance
Β 
Friend function
Friend functionFriend function
Friend function
Β 
Enum
EnumEnum
Enum
Β 

Recently uploaded

ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
Β 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
Β 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
Β 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
Β 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
Β 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
Β 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
Β 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
Β 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
Β 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
Β 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)Dr. Mazin Mohamed alkathiri
Β 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
Β 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxabhijeetpadhi001
Β 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
Β 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
Β 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
Β 

Recently uploaded (20)

ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
Β 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
Β 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
Β 
Model Call Girl in Tilak Nagar Delhi reach out to us at πŸ”9953056974πŸ”
Model Call Girl in Tilak Nagar Delhi reach out to us at πŸ”9953056974πŸ”Model Call Girl in Tilak Nagar Delhi reach out to us at πŸ”9953056974πŸ”
Model Call Girl in Tilak Nagar Delhi reach out to us at πŸ”9953056974πŸ”
Β 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
Β 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
Β 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
Β 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Β 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
Β 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Β 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
Β 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
Β 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
Β 
Model Call Girl in Bikash Puri Delhi reach out to us at πŸ”9953056974πŸ”
Model Call Girl in Bikash Puri  Delhi reach out to us at πŸ”9953056974πŸ”Model Call Girl in Bikash Puri  Delhi reach out to us at πŸ”9953056974πŸ”
Model Call Girl in Bikash Puri Delhi reach out to us at πŸ”9953056974πŸ”
Β 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
Β 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptx
Β 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
Β 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
Β 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
Β 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
Β 

Polymorphism

  • 2. Topics: 1. What is Polymorphism? 2. What is Polymorphism in OOP? 3. How Polymorphism can be achieved? 4. Types of Polymorphism 5. Function Overloading 6. Function Overriding 7. Early Binding 8. Late Binding and Virtual function 9. Pure Virtual Function
  • 3. What is Polymorphism? The process of representing one form in multiple form in known as polymorphism . Typically, polymorphism occurs when there is a hierarchy of classes and they are related by inheritance. It means that a call to a member function will cause a different function to be executed depending on the type of object that invokes the function.
  • 4. What is Polymorphism in OOP? After the inheritance it is another most important feature of OOP. In polymorphism, the member functions with same name are define in base class and also in each derived class. Polymorphism is used to keep the interface of base class to its derived classes. Polymorphism can be achieved by mean of virtual functions. In polymorphism one pointer to a base class object may also point any object of its derived class.
  • 5. How Polymorphism can be achieved: Polymorphism can be achieved in Three ways: 1. Function Overloading 2. Function Overriding 3. Dynamic Binding.
  • 6. Types of Polymorphism: Fig: Types of polymorphism Polymorphism Static Polymorphism : Compile time/ static/Early Binding Dynamic Polymorphism: Runtime/Dynamic/Late Binding
  • 7. Types of Polymorphism: Static Polymorphism: It takes place during Compile time. Function Overloading, Operator Overloading implements static polymorphism. Dynamic Polymorphism: It takes place during Run time. The member function whice change Their behavior during run time called Virtual Functions.
  • 8. Function Overloading Here we have multiple definitions for the same function name in the same scope. The definition of the function must differ from each other by the types and/or the numberof arguments in the argument list.
  • 9. Function Overriding Overriding of functions happens when one class inherits another class. Here functions of both class have the same name and there world be same parameter list and return type of the functions should be same.
  • 10. Early Binding Events occurring at compile time are known as early binding. In the process of early binding all info which is required for a function call is known at compile time. Examples of early binding: function calls, overloaded function calls, and overloaded operators.
  • 11. Late Binding and Virtual Function: All the Code is understood at the Time of Execution This is called as Late Binding. As we Know that Late Binding is Performed By using the virtual Functions. Virtual Means Function must be Override. Virtual Function is a function in base class, which is overrided in the derived class, and which tells the compiler to perform Late Binding on this function.
  • 12. Pure Virtual Function The virtual function that is only declare But Not Define In The InThe Base Class. General Syntax: virtual function_name()=0; The class that contains the pure virtual function exists only to act as base or parent classes.