Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
MEWAR INSTITUTE OF MANAGEMENT
SUBMITTED TO: ASHEESH PANDEY SIR
SUBMITTED BY: SHEETAL SINGH
BCA 2ND YEAR
1590409046
POLYMORPHISM
&
ITS TYPE
POLYMORPHISM
• The process of representing one form in multiple forms is known
as polymorphism
• Polymorphism is derived from 2 Greek words: poly and morphs.
The word "poly" means many and morphs means forms. So
polymorphism means many forms
Real life example
HOWCAN WE ACCESS THE MEMBER OF CLASS
The member of class can be access through pointer to the
class
General syntax
P->member class;
P is pointer of object
-> is member access operator
Member class it is the member of the object

Recommended for you

Polymorphism in C++
Polymorphism in C++Polymorphism in C++
Polymorphism in C++

This document discusses polymorphism in C++. It defines static polymorphism as function overloading and overriding, where functions can have the same name but different parameters. Dynamic polymorphism uses virtual functions and runtime binding via pointers. Virtual functions allow overriding in derived classes. Pure virtual functions make a class abstract, requiring implementation in derived classes. Interface classes are like abstract classes but inheritance is not required.

c programmingprogrammingc++
Polymorphism In Java
Polymorphism In JavaPolymorphism In Java
Polymorphism In Java

Learn the various forms of polymorphism in Java with illustrative examples to explain method overloading(Compile-time polymorphism) and method overriding(Run-time polymorphism)

javajava languagejava class
Operator overloading
Operator overloadingOperator overloading
Operator overloading

In computer programming, operator overloading, sometimes termed operator ad hoc polymorphism, is a specific case of polymorphism, where different operators have different implementations depending on their arguments. Operator overloading is generally defined by a programming language, a programmer, or both. ↓↓↓↓ Read More: @ Kindly Follow my Instagram Page to discuss about your mental health problems- -----> https://instagram.com/mentality_streak?utm_medium=copy_link @ Appreciate my work: -----> behance.net/burhanahmed1 Thank-you !

operatoroverloading
POLYMORPHISM
COMPILE TIME
POLYMORPHIS
M
RUN TIME
POLYMORPHIS
M
FUNCTION
OVERLODIN
G
OPERATOR
OVERLODIN
G
VIRTUAL
FUNCTION
COMPILE TIME POLYMORPHISM
• It is also known as static binding, early binding and overloading as
well
• It provides fast execution because known early at compile time
compile time
• Polymorphism is less flexible as all things execute at compile time.
• It is achieved by function overloading and operator overloading
COMPILE TIME POLYMORPHISM
FUNCTION OVERLOADING
• Overloading refers to the use
of the same thing for different
purpose
• Function overloading is a
logical method of calling
several function with different
datatype and argument but
name of function is the same
OPERATOR OVERLOADING
• In C++ the overloading principle
applies not only to functions, but to
operators too.
• Overloaded operator is used to
perform operation on user-defined
data type. For example '+' operator
can be overloaded to perform
addition on various data types, like
for integer, string(concatenation) etc.
RUN TIME POLYMORPHISM
• It is also known as dynamic binding, late binding and overriding as
well
• It provides slow execution as compare to early binding because it
is known at runtime
• Run time polymorphism is more flexible as all things execute at
run time.
• It is achieved by virtual functions and pointers

Recommended for you

Polymorphism
PolymorphismPolymorphism
Polymorphism

Polymorphism refers to an object's ability to take on multiple forms. In object-oriented programming, polymorphism occurs when an entity such as a variable, function, or object can have more than one form. There are two main types of polymorphism: compile-time polymorphism (such as function and operator overloading) and runtime polymorphism (using virtual functions). Polymorphism allows programmers to work with general classes and let the runtime system handle the specific types, providing flexibility.

polymorphismjavaoop
Polymorphism in c++(ppt)
Polymorphism in c++(ppt)Polymorphism in c++(ppt)
Polymorphism in c++(ppt)

This presentation is about Polymorphism in c++ covering topic types of polymorphism,it's types and real life example of Polymorphism.

learningclassroomengineering
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java

This document discusses polymorphism and inheritance concepts in Java. It defines polymorphism as an object taking on many forms, and describes method overloading and overriding. Method overloading allows classes to have multiple methods with the same name but different parameters. Method overriding allows subclasses to provide a specific implementation of a method in the parent class. The document also discusses abstract classes and interfaces for abstraction in Java, and explains access modifiers like public, private, protected, and default.

polymorphism in javamethod overloading in javamethod overriding in java
VIRTUAL FUNCTION
It is a special type of function
It can be declared within base class and redefine by derived class
Its name will be same in every class
In derived class it will be executed through pointer of base class
It is declared by the keyword “virtual”
A redefined function is said to override the base class function
PROGRAM RELATED
TO
VIRTUAL FUNCTION
#include<iostream.h>
class base{
public:
void display()
{cout<<“display base”;}
virtual void show()
{cout<<“nshow base”;}
};
class derived : public
base
{
public:
void display()
{cout<<“n display
derived”;}
void show()
{cout<<“n show derived”;}
};
int main()
{
base b;
derived d;
base*bptr;
cout<<“n bptr points to
base”;
bptr=&b;
bptr->display();
Bptr->show();
Cout<<“n bptr points to
derived”;
Bptr=&d;
Bptr->display();
Bptr->show();
Return 0;
}
OUTPUT
bptr points to base
display base
show case
bptr points to derived
display base
show derived

Recommended for you

Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading

Operator overloading allows user-defined types in C++ to behave similarly to built-in types when operators are used on them. It allows operators to have special meanings depending on the context. Some key points made in the document include: - Operator overloading enhances the extensibility of C++ by allowing user-defined types to work with operators like addition, subtraction, etc. - Common operators that can be overloaded include arithmetic operators, increment/decrement, input/output, function call, and subscript operators. - To overload an operator, a member or friend function is declared with the same name as the operator being overloaded. This function performs the desired operation on the class type. -

operator overloadingtype conversion
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)

This document provides an overview of basic object-oriented programming (OOP) concepts including objects, classes, inheritance, polymorphism, encapsulation, and data abstraction. It defines objects as entities with both data (characteristics) and behavior (operations). Classes are blueprints that are used to create objects. Inheritance allows objects to inherit properties from parent classes. Polymorphism allows code to take different forms. Encapsulation wraps data and functions into classes, hiding information. Data abstraction focuses on important descriptions without details.

javaoopconcepts
Virtual base class
Virtual base classVirtual base class
Virtual base class

This document discusses the diamond problem that can occur with multiple inheritance in C++. Specifically, it shows an example where a class "four" inherits from classes "two" and "three", which both inherit from class "one". This results in two copies of the base class "one" being present in objects of class "four", leading to ambiguity when trying to access attributes from the base class. The document presents two ways to resolve this issue: 1) manual selection using scope resolution to specify which attribute to access, and 2) making the inheritance of the base class "one" virtual in classes "two" and "three", which ensures only one copy of the base class exists in class "four" objects. The virtual

virtualc++c
RULES OF VIRTUAL FUNCTION
• Virtual function must be member of some class
• They can’t static member
• Virtual function can be a friend of another class
• We can’t have virtual constructor but we have virtual destructor
• Virtual function is define in the base class it is not necessary to redefine in the
derived class
PURE VIRTUAL FUNCTION
• Pure virtual function give small definition to the abstract class . we
need at least one pure virtual function to create abstract class
• Pure virtual function must be define outside the function if it will
define inside the function then compiler show error
polymorphism ppt

More Related Content

What's hot

Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
Shubham Dwivedi
 
Polymorphism presentation in java
Polymorphism presentation in javaPolymorphism presentation in java
Polymorphism presentation in java
Ahsan Raja
 
OOP - Polymorphism
OOP - PolymorphismOOP - Polymorphism
OOP - Polymorphism
Mudasir Qazi
 
Polymorphism in C++
Polymorphism in C++Polymorphism in C++
Polymorphism in C++
Rabin BK
 
Polymorphism In Java
Polymorphism In JavaPolymorphism In Java
Polymorphism In Java
Spotle.ai
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
Burhan Ahmed
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Kumar Gaurav
 
Polymorphism in c++(ppt)
Polymorphism in c++(ppt)Polymorphism in c++(ppt)
Polymorphism in c++(ppt)
Sanjit Shaw
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
Elizabeth alexander
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
Nilesh Dalvi
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
Virtual base class
Virtual base classVirtual base class
Virtual base class
Tech_MX
 
Polymorphism in Python
Polymorphism in Python Polymorphism in Python
Polymorphism in Python
Home
 
Oops concept in c++ unit 3 -topic 4
Oops concept in c++ unit 3 -topic 4Oops concept in c++ unit 3 -topic 4
Oops concept in c++ unit 3 -topic 4
MOHIT TOMAR
 
Polymorphism in java, method overloading and method overriding
Polymorphism in java,  method overloading and method overridingPolymorphism in java,  method overloading and method overriding
Polymorphism in java, method overloading and method overriding
JavaTportal
 
Polymorphism and its types
Polymorphism and its typesPolymorphism and its types
Polymorphism and its types
Suraj Bora
 
Polymorphism in Java
Polymorphism in JavaPolymorphism in Java
Polymorphism in Java
Java2Blog
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
backdoor
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
Lovely Professional University
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
harsh kothari
 

What's hot (20)

Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
 
Polymorphism presentation in java
Polymorphism presentation in javaPolymorphism presentation in java
Polymorphism presentation in java
 
OOP - Polymorphism
OOP - PolymorphismOOP - Polymorphism
OOP - Polymorphism
 
Polymorphism in C++
Polymorphism in C++Polymorphism in C++
Polymorphism in C++
 
Polymorphism In Java
Polymorphism In JavaPolymorphism In Java
Polymorphism In Java
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Polymorphism in c++(ppt)
Polymorphism in c++(ppt)Polymorphism in c++(ppt)
Polymorphism in c++(ppt)
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
Virtual base class
Virtual base classVirtual base class
Virtual base class
 
Polymorphism in Python
Polymorphism in Python Polymorphism in Python
Polymorphism in Python
 
Oops concept in c++ unit 3 -topic 4
Oops concept in c++ unit 3 -topic 4Oops concept in c++ unit 3 -topic 4
Oops concept in c++ unit 3 -topic 4
 
Polymorphism in java, method overloading and method overriding
Polymorphism in java,  method overloading and method overridingPolymorphism in java,  method overloading and method overriding
Polymorphism in java, method overloading and method overriding
 
Polymorphism and its types
Polymorphism and its typesPolymorphism and its types
Polymorphism and its types
 
Polymorphism in Java
Polymorphism in JavaPolymorphism in Java
Polymorphism in Java
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
 

Viewers also liked

Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Language
satvirsandhu9
 
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
cprogrammings
 
Introduction to microsoft word 2007
Introduction to microsoft word 2007Introduction to microsoft word 2007
Introduction to microsoft word 2007
Abdul-rahaman Bin Abubakar Suleman
 
Microsoft word presentation
Microsoft word presentationMicrosoft word presentation
Microsoft word presentation
egirshovich
 
Slideshare Powerpoint presentation
Slideshare Powerpoint presentationSlideshare Powerpoint presentation
Slideshare Powerpoint presentation
elliehood
 
Slideshare ppt
Slideshare pptSlideshare ppt
Slideshare ppt
Mandy Suzanne
 

Viewers also liked (6)

Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Language
 
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
 
Introduction to microsoft word 2007
Introduction to microsoft word 2007Introduction to microsoft word 2007
Introduction to microsoft word 2007
 
Microsoft word presentation
Microsoft word presentationMicrosoft word presentation
Microsoft word presentation
 
Slideshare Powerpoint presentation
Slideshare Powerpoint presentationSlideshare Powerpoint presentation
Slideshare Powerpoint presentation
 
Slideshare ppt
Slideshare pptSlideshare ppt
Slideshare ppt
 

Similar to polymorphism ppt

OOPS & C++(UNIT 4)
OOPS & C++(UNIT 4)OOPS & C++(UNIT 4)
OOPS & C++(UNIT 4)
SURBHI SAROHA
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Amir Ali
 
Comparison between runtime polymorphism and compile time polymorphism
Comparison between runtime polymorphism and compile time polymorphismComparison between runtime polymorphism and compile time polymorphism
Comparison between runtime polymorphism and compile time polymorphism
CHAITALIUKE1
 
C++ concept of Polymorphism
C++ concept of  PolymorphismC++ concept of  Polymorphism
C++ concept of Polymorphism
kiran Patel
 
Polymorphism 140527082302-phpapp01
Polymorphism 140527082302-phpapp01Polymorphism 140527082302-phpapp01
Polymorphism 140527082302-phpapp01
Engr.Tazeen Ahmed
 
polymorphism OOP.pptx
polymorphism OOP.pptxpolymorphism OOP.pptx
polymorphism OOP.pptx
AssadLeo1
 
polymorphism and virtual function
polymorphism and virtual functionpolymorphism and virtual function
polymorphism and virtual function
Bhanuprataparya
 
polymorphism.pdf
polymorphism.pdfpolymorphism.pdf
polymorphism.pdf
riyawagh2
 
Dynamic Polymorphism in C++
Dynamic Polymorphism in C++Dynamic Polymorphism in C++
Dynamic Polymorphism in C++
Dharmisha Sharma
 
polymorpisum-140106223024-phpapp01.pdf
polymorpisum-140106223024-phpapp01.pdfpolymorpisum-140106223024-phpapp01.pdf
polymorpisum-140106223024-phpapp01.pdf
BapanKar2
 
polymorphism-17013114666666666653806.pdf
polymorphism-17013114666666666653806.pdfpolymorphism-17013114666666666653806.pdf
polymorphism-17013114666666666653806.pdf
kashafishfaq21
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Nochiketa Chakraborty
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
zindadili
 
Oopsecondgrouppresentation 180726073512-converted (1)
Oopsecondgrouppresentation 180726073512-converted (1)Oopsecondgrouppresentation 180726073512-converted (1)
Oopsecondgrouppresentation 180726073512-converted (1)
Hassan Hashmi
 
Polymorphism.Difference between Inheritance & Polymorphism
Polymorphism.Difference between Inheritance & PolymorphismPolymorphism.Difference between Inheritance & Polymorphism
Polymorphism.Difference between Inheritance & Polymorphism
huzaifaakram12
 
Virtual function
Virtual functionVirtual function
Virtual function
zindadili
 
Polymorphism & inheritence ppt
Polymorphism & inheritence pptPolymorphism & inheritence ppt
Polymorphism & inheritence ppt
arunsingh660
 
Polymorphism ppt
Polymorphism pptPolymorphism ppt
Polymorphism ppt
arunsingh660
 
Oop lecture 06
Oop lecture 06Oop lecture 06
Oop lecture 06
University of Chitral
 
virtual function
virtual functionvirtual function
virtual function
VENNILAV6
 

Similar to polymorphism ppt (20)

OOPS & C++(UNIT 4)
OOPS & C++(UNIT 4)OOPS & C++(UNIT 4)
OOPS & C++(UNIT 4)
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Comparison between runtime polymorphism and compile time polymorphism
Comparison between runtime polymorphism and compile time polymorphismComparison between runtime polymorphism and compile time polymorphism
Comparison between runtime polymorphism and compile time polymorphism
 
C++ concept of Polymorphism
C++ concept of  PolymorphismC++ concept of  Polymorphism
C++ concept of Polymorphism
 
Polymorphism 140527082302-phpapp01
Polymorphism 140527082302-phpapp01Polymorphism 140527082302-phpapp01
Polymorphism 140527082302-phpapp01
 
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
 
Dynamic Polymorphism in C++
Dynamic Polymorphism in C++Dynamic Polymorphism in C++
Dynamic Polymorphism in C++
 
polymorpisum-140106223024-phpapp01.pdf
polymorpisum-140106223024-phpapp01.pdfpolymorpisum-140106223024-phpapp01.pdf
polymorpisum-140106223024-phpapp01.pdf
 
polymorphism-17013114666666666653806.pdf
polymorphism-17013114666666666653806.pdfpolymorphism-17013114666666666653806.pdf
polymorphism-17013114666666666653806.pdf
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Oopsecondgrouppresentation 180726073512-converted (1)
Oopsecondgrouppresentation 180726073512-converted (1)Oopsecondgrouppresentation 180726073512-converted (1)
Oopsecondgrouppresentation 180726073512-converted (1)
 
Polymorphism.Difference between Inheritance & Polymorphism
Polymorphism.Difference between Inheritance & PolymorphismPolymorphism.Difference between Inheritance & Polymorphism
Polymorphism.Difference between Inheritance & Polymorphism
 
Virtual function
Virtual functionVirtual function
Virtual function
 
Polymorphism & inheritence ppt
Polymorphism & inheritence pptPolymorphism & inheritence ppt
Polymorphism & inheritence ppt
 
Polymorphism ppt
Polymorphism pptPolymorphism ppt
Polymorphism ppt
 
Oop lecture 06
Oop lecture 06Oop lecture 06
Oop lecture 06
 
virtual function
virtual functionvirtual function
virtual function
 

polymorphism ppt

  • 1. MEWAR INSTITUTE OF MANAGEMENT SUBMITTED TO: ASHEESH PANDEY SIR SUBMITTED BY: SHEETAL SINGH BCA 2ND YEAR 1590409046
  • 3. POLYMORPHISM • The process of representing one form in multiple forms is known as polymorphism • Polymorphism is derived from 2 Greek words: poly and morphs. The word "poly" means many and morphs means forms. So polymorphism means many forms Real life example
  • 4. HOWCAN WE ACCESS THE MEMBER OF CLASS The member of class can be access through pointer to the class General syntax P->member class; P is pointer of object -> is member access operator Member class it is the member of the object
  • 6. COMPILE TIME POLYMORPHISM • It is also known as static binding, early binding and overloading as well • It provides fast execution because known early at compile time compile time • Polymorphism is less flexible as all things execute at compile time. • It is achieved by function overloading and operator overloading
  • 7. COMPILE TIME POLYMORPHISM FUNCTION OVERLOADING • Overloading refers to the use of the same thing for different purpose • Function overloading is a logical method of calling several function with different datatype and argument but name of function is the same OPERATOR OVERLOADING • In C++ the overloading principle applies not only to functions, but to operators too. • Overloaded operator is used to perform operation on user-defined data type. For example '+' operator can be overloaded to perform addition on various data types, like for integer, string(concatenation) etc.
  • 8. RUN TIME POLYMORPHISM • It is also known as dynamic binding, late binding and overriding as well • It provides slow execution as compare to early binding because it is known at runtime • Run time polymorphism is more flexible as all things execute at run time. • It is achieved by virtual functions and pointers
  • 9. VIRTUAL FUNCTION It is a special type of function It can be declared within base class and redefine by derived class Its name will be same in every class In derived class it will be executed through pointer of base class It is declared by the keyword “virtual” A redefined function is said to override the base class function
  • 11. #include<iostream.h> class base{ public: void display() {cout<<“display base”;} virtual void show() {cout<<“nshow base”;} }; class derived : public base { public: void display() {cout<<“n display derived”;} void show() {cout<<“n show derived”;} }; int main() { base b; derived d; base*bptr; cout<<“n bptr points to base”; bptr=&b; bptr->display(); Bptr->show(); Cout<<“n bptr points to derived”; Bptr=&d; Bptr->display(); Bptr->show(); Return 0; }
  • 12. OUTPUT bptr points to base display base show case bptr points to derived display base show derived
  • 13. RULES OF VIRTUAL FUNCTION • Virtual function must be member of some class • They can’t static member • Virtual function can be a friend of another class • We can’t have virtual constructor but we have virtual destructor • Virtual function is define in the base class it is not necessary to redefine in the derived class
  • 14. PURE VIRTUAL FUNCTION • Pure virtual function give small definition to the abstract class . we need at least one pure virtual function to create abstract class • Pure virtual function must be define outside the function if it will define inside the function then compiler show error