SlideShare a Scribd company logo
POLYMORPHISM IN C++
Haldia Institute of Technology
Presented By : -
Name Roll no.
Purabi Biswas 14/CS/70
Sanjit Shaw B14/CS/127
Shubham Singhanaia B14/CS/127
(Computer Science & Engineering)
POLYMORPHISM
The process of representing one Form in multiple forms is
known as Polymorphism. Here one form represent original
form or original method always resides in base class and
multiple forms represents overridden method which resides in
derived classes.
Polymorphism is derived from 2 Greek words: poly and
morphs. The word "poly" means many and morphs means
forms.
Real life example of Polymorphism
Suppose if you are in class room that time you behave
like a student, when you are in market at that time you
behave like a customer, when you at your home at that
time you behave like a son or daughter, Here one person
have different-different behaviors.
Type of Polymorphism
 Static polymorphism is also known as early binding and compile-time polymorphism.
In static polymorphism memory will be allocated at compile-time.
 Dynamic polymorphism is also known as late binding and run-time polymorphism. In
dynamic polymorphism memory will be allocated at run-time.
Polymorphism
Static
Function
Overloading
Operator
Overloading
Dynamic
Virtual
Functions
Method Overloading
Whenever same method name is exiting multiple times in the same class with
different number of parameter or different order of parameters or different types of
parameters is known as method overloading.
In next example method "sum()" is present in Addition class with same name but
with different signature or arguments.
Function Overloading Example
class Addition {
public: void sum(int a, int b) {
cout<<"a+b :"<<a+b; } //output :- a+b : 30
void sum(int a, int b, int c) {
cout<<"a+b+c :"<<a+b+c; } //output :- a+b+c : 60
};
int main() {
Addition obj;
obj.sum(10, 20);
cout<<endl;
obj.sum(10, 20, 30); }
Operator Overloading
The process of making an operator to exhibit different behaviors in different
instances is known as operator overloading.
Only predefined operator can be overloaded.
Types Of Operator Overloading
Unary operator overloading.
These Operators have only single operand.
Examples:- ++,--,~,!
Binary operator overloading.
These operators can have two or more operands.
Examples:-+,-,*,/,%,^,=,==,+=,&,&& etc
Operator Overloading Example
class complex{ int main(){
private:: complex c1,c2,c3;
int a,b; c1.set_data(3,4);
public:void set_data(int x,int y){ c2.set_data(5,6);
a=x;b=y;} c3=c1.add+(c2);
void show_data(){ c3.show_data();
cout<<“n a=“<<a<<“b=“<<b;} return 0;}
complex add+(complex c){
complex temp ;
temp.a=a+c.a;
temp.b=b+c.b;
return temp;}};
Virtual Function
A virtual function is a member function that is declared as virtual within a base
class and redefined by a derived class.
 To create virtual function, precede the base version of function’s declaration with
the keyword virtual.
 Here we use a pointer to the base class to refer to all the derived objects.
 The method name and type signature should be same for both base and derived
version of function.
Using Virtual Keyword Example
class A {
public: virtual void show() {
cout<<"Content of base class.n"; }};
class B : public A {
public: void show() {
cout<<"Content of derived class.n"; } };
int main() {
A b,*bptr; //Base class pointer
B d; //Derived class object
bptr = &b;
bptr->show(); //Late Binding Occurs
Bptr=&d;
Bptr->show();
return 0; }
Special Thanks To:-
Mrs. Rajrupa Metia
(Asst. Professor)
Computer Science & Engineering
Ad

More Related Content

What's hot (20)

Function overloading(c++)
Function overloading(c++)Function overloading(c++)
Function overloading(c++)
Ritika Sharma
 
Inline function
Inline functionInline function
Inline function
Tech_MX
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
HalaiHansaika
 
Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function
Kamlesh Makvana
 
Polymorphism in C++
Polymorphism in C++Polymorphism in C++
Polymorphism in C++
Rabin BK
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
Rokonuzzaman Rony
 
Method overloading
Method overloadingMethod overloading
Method overloading
Lovely Professional University
 
Function overloading and overriding
Function overloading and overridingFunction overloading and overriding
Function overloading and overriding
Rajab Ali
 
08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt
Tareq Hasan
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
Dhrumil Panchal
 
Templates in c++
Templates in c++Templates in c++
Templates in c++
ThamizhselviKrishnam
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
Muhammad Waqas
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
03062679929
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
harsh kothari
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
Mayank Jain
 
Basic concept of OOP's
Basic concept of OOP'sBasic concept of OOP's
Basic concept of OOP's
Prof. Dr. K. Adisesha
 
Encapsulation C++
Encapsulation C++Encapsulation C++
Encapsulation C++
Hashim Hashim
 
Operator Overloading & Function Overloading
Operator Overloading & Function OverloadingOperator Overloading & Function Overloading
Operator Overloading & Function Overloading
Meghaj Mallick
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
Nilesh Dalvi
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
Vineeta Garg
 
Function overloading(c++)
Function overloading(c++)Function overloading(c++)
Function overloading(c++)
Ritika Sharma
 
Inline function
Inline functionInline function
Inline function
Tech_MX
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
HalaiHansaika
 
Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function
Kamlesh Makvana
 
Polymorphism in C++
Polymorphism in C++Polymorphism in C++
Polymorphism in C++
Rabin BK
 
Function overloading and overriding
Function overloading and overridingFunction overloading and overriding
Function overloading and overriding
Rajab Ali
 
08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt
Tareq Hasan
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
Dhrumil Panchal
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
Muhammad Waqas
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
03062679929
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
Mayank Jain
 
Operator Overloading & Function Overloading
Operator Overloading & Function OverloadingOperator Overloading & Function Overloading
Operator Overloading & Function Overloading
Meghaj Mallick
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
Nilesh Dalvi
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
Vineeta Garg
 

Viewers also liked (20)

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
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Raffaele Doti
 
Static and Dynamic polymorphism in C++
Static and Dynamic polymorphism in C++Static and Dynamic polymorphism in C++
Static and Dynamic polymorphism in C++
Anil Bapat
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Kumar Gaurav
 
Dynamic Polymorphism in C++
Dynamic Polymorphism in C++Dynamic Polymorphism in C++
Dynamic Polymorphism in C++
Dharmisha Sharma
 
polymorphism
polymorphism polymorphism
polymorphism
Imtiaz Hussain
 
Seminar on polymorphism
Seminar on polymorphismSeminar on polymorphism
Seminar on polymorphism
023henil
 
A survey of distributed deadlock detection algorithms
A survey of distributed deadlock detection algorithmsA survey of distributed deadlock detection algorithms
A survey of distributed deadlock detection algorithms
anaykh1992
 
[OOP - Lec 07] Access Specifiers
[OOP - Lec 07] Access Specifiers[OOP - Lec 07] Access Specifiers
[OOP - Lec 07] Access Specifiers
Muhammad Hammad Waseem
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
ushabarad142
 
C++ polymorphism
C++ polymorphismC++ polymorphism
C++ polymorphism
Ganesh Hogade
 
E wallet
E walletE wallet
E wallet
Ρяιтz ЯΑЅКΑℓ●๋•
 
Business plan: social networking website
Business plan: social networking website Business plan: social networking website
Business plan: social networking website
Dr. Trilok Kumar Jain
 
E wallet- final
E wallet- finalE wallet- final
E wallet- final
Anshuman Roy
 
Slide 2 data models
Slide 2 data modelsSlide 2 data models
Slide 2 data models
Visakh V
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
Laxman Puri
 
E wallet by amin
E wallet by aminE wallet by amin
E wallet by amin
aminpathan11
 
Underwater wireless communication
Underwater wireless communicationUnderwater wireless communication
Underwater wireless communication
Abhirami P S
 
E wallet
E walletE wallet
E wallet
anuja joshi
 
E-Wallet Platform 2017
E-Wallet Platform 2017E-Wallet Platform 2017
E-Wallet Platform 2017
Mikhail Miroshnichenko
 
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
 
Static and Dynamic polymorphism in C++
Static and Dynamic polymorphism in C++Static and Dynamic polymorphism in C++
Static and Dynamic polymorphism in C++
Anil Bapat
 
Dynamic Polymorphism in C++
Dynamic Polymorphism in C++Dynamic Polymorphism in C++
Dynamic Polymorphism in C++
Dharmisha Sharma
 
Seminar on polymorphism
Seminar on polymorphismSeminar on polymorphism
Seminar on polymorphism
023henil
 
A survey of distributed deadlock detection algorithms
A survey of distributed deadlock detection algorithmsA survey of distributed deadlock detection algorithms
A survey of distributed deadlock detection algorithms
anaykh1992
 
Business plan: social networking website
Business plan: social networking website Business plan: social networking website
Business plan: social networking website
Dr. Trilok Kumar Jain
 
Slide 2 data models
Slide 2 data modelsSlide 2 data models
Slide 2 data models
Visakh V
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
Laxman Puri
 
Underwater wireless communication
Underwater wireless communicationUnderwater wireless communication
Underwater wireless communication
Abhirami P S
 
Ad

Similar to Polymorphism in c++(ppt) (20)

vdocument in_polymorphism-in-cppt_python.pdf
vdocument in_polymorphism-in-cppt_python.pdfvdocument in_polymorphism-in-cppt_python.pdf
vdocument in_polymorphism-in-cppt_python.pdf
parveen204931475
 
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
 
Java Polymorphism
Java PolymorphismJava Polymorphism
Java Polymorphism
Soba Arjun
 
oops.pptx
oops.pptxoops.pptx
oops.pptx
ASHWINAIT2021
 
Polymorphism & inheritence ppt
Polymorphism & inheritence pptPolymorphism & inheritence ppt
Polymorphism & inheritence ppt
arunsingh660
 
Polymorphism ppt
Polymorphism pptPolymorphism ppt
Polymorphism ppt
arunsingh660
 
Polymorphism.Difference between Inheritance & Polymorphism
Polymorphism.Difference between Inheritance & PolymorphismPolymorphism.Difference between Inheritance & Polymorphism
Polymorphism.Difference between Inheritance & Polymorphism
huzaifaakram12
 
polymorphism.pdf
polymorphism.pdfpolymorphism.pdf
polymorphism.pdf
riyawagh2
 
Polymorphism and Type Conversion.pdf pot
Polymorphism and Type Conversion.pdf potPolymorphism and Type Conversion.pdf pot
Polymorphism and Type Conversion.pdf pot
e13225064
 
polymorphism for b.tech iii year students
polymorphism for b.tech iii year studentspolymorphism for b.tech iii year students
polymorphism for b.tech iii year students
Somesh Kumar
 
polymorphsim in objerientect i language s
polymorphsim in objerientect i language spolymorphsim in objerientect i language s
polymorphsim in objerientect i language s
sufiyansiddique2
 
polymorphsim in Object oriented language
polymorphsim in Object oriented languagepolymorphsim in Object oriented language
polymorphsim in Object oriented language
sufiyansiddique2
 
Oop concepts
Oop conceptsOop concepts
Oop concepts
baabtra.com - No. 1 supplier of quality freshers
 
Presentation on polymorphism in c++.pptx
Presentation on polymorphism in c++.pptxPresentation on polymorphism in c++.pptx
Presentation on polymorphism in c++.pptx
vishwadeep15
 
java poly ppt.pptx
java poly ppt.pptxjava poly ppt.pptx
java poly ppt.pptx
sukhpreetsingh295239
 
Polymorphism in c++
Polymorphism in c++Polymorphism in c++
Polymorphism in c++
Dheenadayalan18
 
polymorphism ppt
polymorphism pptpolymorphism ppt
polymorphism ppt
sheetal singh
 
What Swift can teach us all
What Swift can teach us allWhat Swift can teach us all
What Swift can teach us all
Pablo Villar
 
Oopsecondgrouppresentation 180726073512-converted (1)
Oopsecondgrouppresentation 180726073512-converted (1)Oopsecondgrouppresentation 180726073512-converted (1)
Oopsecondgrouppresentation 180726073512-converted (1)
Hassan Hashmi
 
Minimal Introduction to C++ - Part III - Final
Minimal Introduction to C++ - Part III - FinalMinimal Introduction to C++ - Part III - Final
Minimal Introduction to C++ - Part III - Final
Michel Alves
 
vdocument in_polymorphism-in-cppt_python.pdf
vdocument in_polymorphism-in-cppt_python.pdfvdocument in_polymorphism-in-cppt_python.pdf
vdocument in_polymorphism-in-cppt_python.pdf
parveen204931475
 
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
 
Java Polymorphism
Java PolymorphismJava Polymorphism
Java Polymorphism
Soba Arjun
 
Polymorphism & inheritence ppt
Polymorphism & inheritence pptPolymorphism & inheritence ppt
Polymorphism & inheritence ppt
arunsingh660
 
Polymorphism.Difference between Inheritance & Polymorphism
Polymorphism.Difference between Inheritance & PolymorphismPolymorphism.Difference between Inheritance & Polymorphism
Polymorphism.Difference between Inheritance & Polymorphism
huzaifaakram12
 
polymorphism.pdf
polymorphism.pdfpolymorphism.pdf
polymorphism.pdf
riyawagh2
 
Polymorphism and Type Conversion.pdf pot
Polymorphism and Type Conversion.pdf potPolymorphism and Type Conversion.pdf pot
Polymorphism and Type Conversion.pdf pot
e13225064
 
polymorphism for b.tech iii year students
polymorphism for b.tech iii year studentspolymorphism for b.tech iii year students
polymorphism for b.tech iii year students
Somesh Kumar
 
polymorphsim in objerientect i language s
polymorphsim in objerientect i language spolymorphsim in objerientect i language s
polymorphsim in objerientect i language s
sufiyansiddique2
 
polymorphsim in Object oriented language
polymorphsim in Object oriented languagepolymorphsim in Object oriented language
polymorphsim in Object oriented language
sufiyansiddique2
 
Presentation on polymorphism in c++.pptx
Presentation on polymorphism in c++.pptxPresentation on polymorphism in c++.pptx
Presentation on polymorphism in c++.pptx
vishwadeep15
 
What Swift can teach us all
What Swift can teach us allWhat Swift can teach us all
What Swift can teach us all
Pablo Villar
 
Oopsecondgrouppresentation 180726073512-converted (1)
Oopsecondgrouppresentation 180726073512-converted (1)Oopsecondgrouppresentation 180726073512-converted (1)
Oopsecondgrouppresentation 180726073512-converted (1)
Hassan Hashmi
 
Minimal Introduction to C++ - Part III - Final
Minimal Introduction to C++ - Part III - FinalMinimal Introduction to C++ - Part III - Final
Minimal Introduction to C++ - Part III - Final
Michel Alves
 
Ad

Recently uploaded (20)

How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18
Celine George
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon DolabaniHistory Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
fruinkamel7m
 
CNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscessCNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscess
Mohamed Rizk Khodair
 
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
Arshad Shaikh
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
Overview Well-Being and Creative Careers
Overview Well-Being and Creative CareersOverview Well-Being and Creative Careers
Overview Well-Being and Creative Careers
University of Amsterdam
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE  BY sweety Tamanna Mahapatra MSc PediatricAPGAR SCORE  BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
SweetytamannaMohapat
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18
Celine George
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon DolabaniHistory Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
fruinkamel7m
 
CNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscessCNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscess
Mohamed Rizk Khodair
 
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
Arshad Shaikh
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
Overview Well-Being and Creative Careers
Overview Well-Being and Creative CareersOverview Well-Being and Creative Careers
Overview Well-Being and Creative Careers
University of Amsterdam
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE  BY sweety Tamanna Mahapatra MSc PediatricAPGAR SCORE  BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
SweetytamannaMohapat
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 

Polymorphism in c++(ppt)

  • 2. Haldia Institute of Technology Presented By : - Name Roll no. Purabi Biswas 14/CS/70 Sanjit Shaw B14/CS/127 Shubham Singhanaia B14/CS/127 (Computer Science & Engineering)
  • 3. POLYMORPHISM The process of representing one Form in multiple forms is known as Polymorphism. Here one form represent original form or original method always resides in base class and multiple forms represents overridden method which resides in derived classes. Polymorphism is derived from 2 Greek words: poly and morphs. The word "poly" means many and morphs means forms.
  • 4. Real life example of Polymorphism Suppose if you are in class room that time you behave like a student, when you are in market at that time you behave like a customer, when you at your home at that time you behave like a son or daughter, Here one person have different-different behaviors.
  • 5. Type of Polymorphism  Static polymorphism is also known as early binding and compile-time polymorphism. In static polymorphism memory will be allocated at compile-time.  Dynamic polymorphism is also known as late binding and run-time polymorphism. In dynamic polymorphism memory will be allocated at run-time. Polymorphism Static Function Overloading Operator Overloading Dynamic Virtual Functions
  • 6. Method Overloading Whenever same method name is exiting multiple times in the same class with different number of parameter or different order of parameters or different types of parameters is known as method overloading. In next example method "sum()" is present in Addition class with same name but with different signature or arguments.
  • 7. Function Overloading Example class Addition { public: void sum(int a, int b) { cout<<"a+b :"<<a+b; } //output :- a+b : 30 void sum(int a, int b, int c) { cout<<"a+b+c :"<<a+b+c; } //output :- a+b+c : 60 }; int main() { Addition obj; obj.sum(10, 20); cout<<endl; obj.sum(10, 20, 30); }
  • 8. Operator Overloading The process of making an operator to exhibit different behaviors in different instances is known as operator overloading. Only predefined operator can be overloaded. Types Of Operator Overloading Unary operator overloading. These Operators have only single operand. Examples:- ++,--,~,! Binary operator overloading. These operators can have two or more operands. Examples:-+,-,*,/,%,^,=,==,+=,&,&& etc
  • 9. Operator Overloading Example class complex{ int main(){ private:: complex c1,c2,c3; int a,b; c1.set_data(3,4); public:void set_data(int x,int y){ c2.set_data(5,6); a=x;b=y;} c3=c1.add+(c2); void show_data(){ c3.show_data(); cout<<“n a=“<<a<<“b=“<<b;} return 0;} complex add+(complex c){ complex temp ; temp.a=a+c.a; temp.b=b+c.b; return temp;}};
  • 10. Virtual Function A virtual function is a member function that is declared as virtual within a base class and redefined by a derived class.  To create virtual function, precede the base version of function’s declaration with the keyword virtual.  Here we use a pointer to the base class to refer to all the derived objects.  The method name and type signature should be same for both base and derived version of function.
  • 11. Using Virtual Keyword Example class A { public: virtual void show() { cout<<"Content of base class.n"; }}; class B : public A { public: void show() { cout<<"Content of derived class.n"; } }; int main() { A b,*bptr; //Base class pointer B d; //Derived class object bptr = &b; bptr->show(); //Late Binding Occurs Bptr=&d; Bptr->show(); return 0; }
  • 12. Special Thanks To:- Mrs. Rajrupa Metia (Asst. Professor) Computer Science & Engineering
  翻译: