Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

More Related Content

What's hot

virtual function
virtual functionvirtual function
virtual function
VENNILAV6
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
Nilesh Dalvi
 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
Ronak Chhajed
 
Function in C program
Function in C programFunction in C program
Function in C program
Nurul Zakiah Zamri Tan
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
Shuvongkor Barman
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
rprajat007
 
Functions in c
Functions in cFunctions in c
Functions in c
sunila tharagaturi
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
Pooja Jaiswal
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
Shubham Dwivedi
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
Vishal Patil
 
Method overriding
Method overridingMethod overriding
Method overriding
Azaz Maverick
 
INLINE FUNCTION IN C++
INLINE FUNCTION IN C++INLINE FUNCTION IN C++
INLINE FUNCTION IN C++
Vraj Patel
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Nochiketa Chakraborty
 
Files in c++ ppt
Files in c++ pptFiles in c++ ppt
Files in c++ ppt
Kumar
 
Encapsulation C++
Encapsulation C++Encapsulation C++
Encapsulation C++
Hashim Hashim
 
Polymorphism Using C++
Polymorphism Using C++Polymorphism Using C++
Polymorphism Using C++
PRINCE KUMAR
 
class and objects
class and objectsclass and objects
class and objects
Payel Guria
 
Inline function
Inline functionInline function
Inline function
Tech_MX
 
friend function(c++)
friend function(c++)friend function(c++)
friend function(c++)
Ritika Sharma
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
harsh kothari
 

What's hot (20)

virtual function
virtual functionvirtual function
virtual function
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
 
Function in C program
Function in C programFunction in C program
Function in C program
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Method overriding
Method overridingMethod overriding
Method overriding
 
INLINE FUNCTION IN C++
INLINE FUNCTION IN C++INLINE FUNCTION IN C++
INLINE FUNCTION IN C++
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Files in c++ ppt
Files in c++ pptFiles in c++ ppt
Files in c++ ppt
 
Encapsulation C++
Encapsulation C++Encapsulation C++
Encapsulation C++
 
Polymorphism Using C++
Polymorphism Using C++Polymorphism Using C++
Polymorphism Using C++
 
class and objects
class and objectsclass and objects
class and objects
 
Inline function
Inline functionInline function
Inline function
 
friend function(c++)
friend function(c++)friend function(c++)
friend function(c++)
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
 

Viewers also liked

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
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
 

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 |...
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Static and Dynamic polymorphism in C++
Static and Dynamic polymorphism in C++Static and Dynamic polymorphism in C++
Static and Dynamic polymorphism in C++
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Dynamic Polymorphism in C++
Dynamic Polymorphism in C++Dynamic Polymorphism in C++
Dynamic Polymorphism in C++
 
polymorphism
polymorphism polymorphism
polymorphism
 
Seminar on polymorphism
Seminar on polymorphismSeminar on polymorphism
Seminar on polymorphism
 
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
 
[OOP - Lec 07] Access Specifiers
[OOP - Lec 07] Access Specifiers[OOP - Lec 07] Access Specifiers
[OOP - Lec 07] Access Specifiers
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
C++ polymorphism
C++ polymorphismC++ polymorphism
C++ polymorphism
 
E wallet
E walletE wallet
E wallet
 
Business plan: social networking website
Business plan: social networking website Business plan: social networking website
Business plan: social networking website
 
E wallet- final
E wallet- finalE wallet- final
E wallet- final
 
Slide 2 data models
Slide 2 data modelsSlide 2 data models
Slide 2 data models
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
E wallet by amin
E wallet by aminE wallet by amin
E wallet by amin
 
Underwater wireless communication
Underwater wireless communicationUnderwater wireless communication
Underwater wireless communication
 
E wallet
E walletE wallet
E wallet
 
E-Wallet Platform 2017
E-Wallet Platform 2017E-Wallet Platform 2017
E-Wallet Platform 2017
 

Similar to Polymorphism in c++(ppt)

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
 
Oop concepts
Oop conceptsOop concepts
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 and its types
Polymorphism and its typesPolymorphism and its types
Polymorphism and its types
Suraj Bora
 
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
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Arif Ansari
 
2CPP10 - Polymorphism
2CPP10 - Polymorphism2CPP10 - Polymorphism
2CPP10 - Polymorphism
Michael Heron
 
Object Oriented Programming - 7.2. Polymorphism
Object Oriented Programming - 7.2. PolymorphismObject Oriented Programming - 7.2. Polymorphism
Object Oriented Programming - 7.2. Polymorphism
AndiNurkholis1
 

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
 
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
 
Java Polymorphism
Java PolymorphismJava Polymorphism
Java Polymorphism
 
oops.pptx
oops.pptxoops.pptx
oops.pptx
 
Polymorphism & inheritence ppt
Polymorphism & inheritence pptPolymorphism & inheritence ppt
Polymorphism & inheritence ppt
 
Polymorphism ppt
Polymorphism pptPolymorphism ppt
Polymorphism ppt
 
Polymorphism.Difference between Inheritance & Polymorphism
Polymorphism.Difference between Inheritance & PolymorphismPolymorphism.Difference between Inheritance & Polymorphism
Polymorphism.Difference between Inheritance & Polymorphism
 
polymorphism.pdf
polymorphism.pdfpolymorphism.pdf
polymorphism.pdf
 
Oop concepts
Oop conceptsOop concepts
Oop concepts
 
Presentation on polymorphism in c++.pptx
Presentation on polymorphism in c++.pptxPresentation on polymorphism in c++.pptx
Presentation on polymorphism in c++.pptx
 
java poly ppt.pptx
java poly ppt.pptxjava poly ppt.pptx
java poly ppt.pptx
 
Polymorphism in c++
Polymorphism in c++Polymorphism in c++
Polymorphism in c++
 
Polymorphism and its types
Polymorphism and its typesPolymorphism and its types
Polymorphism and its types
 
polymorphism ppt
polymorphism pptpolymorphism ppt
polymorphism ppt
 
What Swift can teach us all
What Swift can teach us allWhat Swift can teach us all
What Swift can teach us all
 
Oopsecondgrouppresentation 180726073512-converted (1)
Oopsecondgrouppresentation 180726073512-converted (1)Oopsecondgrouppresentation 180726073512-converted (1)
Oopsecondgrouppresentation 180726073512-converted (1)
 
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
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
2CPP10 - Polymorphism
2CPP10 - Polymorphism2CPP10 - Polymorphism
2CPP10 - Polymorphism
 
Object Oriented Programming - 7.2. Polymorphism
Object Oriented Programming - 7.2. PolymorphismObject Oriented Programming - 7.2. Polymorphism
Object Oriented Programming - 7.2. Polymorphism
 

Recently uploaded

Capitol Doctoral Presentation -June 2024v2.pptx
Capitol Doctoral Presentation -June 2024v2.pptxCapitol Doctoral Presentation -June 2024v2.pptx
Capitol Doctoral Presentation -June 2024v2.pptx
CapitolTechU
 
ENGLISH-7-CURRICULUM MAP- MATATAG CURRICULUM
ENGLISH-7-CURRICULUM MAP- MATATAG CURRICULUMENGLISH-7-CURRICULUM MAP- MATATAG CURRICULUM
ENGLISH-7-CURRICULUM MAP- MATATAG CURRICULUM
HappieMontevirgenCas
 
2024 KWL Back 2 School Summer Conference
2024 KWL Back 2 School Summer Conference2024 KWL Back 2 School Summer Conference
2024 KWL Back 2 School Summer Conference
KlettWorldLanguages
 
How to Install Theme in the Odoo 17 ERP
How to  Install Theme in the Odoo 17 ERPHow to  Install Theme in the Odoo 17 ERP
How to Install Theme in the Odoo 17 ERP
Celine George
 
The basics of sentences session 9pptx.pptx
The basics of sentences session 9pptx.pptxThe basics of sentences session 9pptx.pptx
The basics of sentences session 9pptx.pptx
heathfieldcps1
 
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ..."DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
thanhluan21
 
How to Add Colour Kanban Records in Odoo 17 Notebook
How to Add Colour Kanban Records in Odoo 17 NotebookHow to Add Colour Kanban Records in Odoo 17 Notebook
How to Add Colour Kanban Records in Odoo 17 Notebook
Celine George
 
Split Shifts From Gantt View in the Odoo 17
Split Shifts From Gantt View in the  Odoo 17Split Shifts From Gantt View in the  Odoo 17
Split Shifts From Gantt View in the Odoo 17
Celine George
 
Beyond the Advance Presentation for By the Book 9
Beyond the Advance Presentation for By the Book 9Beyond the Advance Presentation for By the Book 9
Beyond the Advance Presentation for By the Book 9
John Rodzvilla
 
Traces of the Holocaust in our communities in Levice Sovakia and Constanta Ro...
Traces of the Holocaust in our communities in Levice Sovakia and Constanta Ro...Traces of the Holocaust in our communities in Levice Sovakia and Constanta Ro...
Traces of the Holocaust in our communities in Levice Sovakia and Constanta Ro...
Zuzana Mészárosová
 
DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...
DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...
DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...
thanhluan21
 
L1 L2- NLC PPT for Grade 10 intervention
L1 L2- NLC PPT for Grade 10 interventionL1 L2- NLC PPT for Grade 10 intervention
L1 L2- NLC PPT for Grade 10 intervention
RHODAJANEAURESTILA
 
AI_in_HR_Presentation Part 1 2024 0703.pdf
AI_in_HR_Presentation Part 1 2024 0703.pdfAI_in_HR_Presentation Part 1 2024 0703.pdf
AI_in_HR_Presentation Part 1 2024 0703.pdf
SrimanigandanMadurai
 
The membership Module in the Odoo 17 ERP
The membership Module in the Odoo 17 ERPThe membership Module in the Odoo 17 ERP
The membership Module in the Odoo 17 ERP
Celine George
 
NLC Grade 3.................................... ppt.pptx
NLC Grade 3.................................... ppt.pptxNLC Grade 3.................................... ppt.pptx
NLC Grade 3.................................... ppt.pptx
MichelleDeLaCruz93
 
Is Email Marketing Really Effective In 2024?
Is Email Marketing Really Effective In 2024?Is Email Marketing Really Effective In 2024?
Is Email Marketing Really Effective In 2024?
Rakesh Jalan
 
Principles of Roods Approach!!!!!!!.pptx
Principles of Roods Approach!!!!!!!.pptxPrinciples of Roods Approach!!!!!!!.pptx
Principles of Roods Approach!!!!!!!.pptx
ibtesaam huma
 
Delegation Inheritance in Odoo 17 and Its Use Cases
Delegation Inheritance in Odoo 17 and Its Use CasesDelegation Inheritance in Odoo 17 and Its Use Cases
Delegation Inheritance in Odoo 17 and Its Use Cases
Celine George
 
Chapter-2-Era-of-One-party-Dominance-Class-12-Political-Science-Notes-2 (1).pptx
Chapter-2-Era-of-One-party-Dominance-Class-12-Political-Science-Notes-2 (1).pptxChapter-2-Era-of-One-party-Dominance-Class-12-Political-Science-Notes-2 (1).pptx
Chapter-2-Era-of-One-party-Dominance-Class-12-Political-Science-Notes-2 (1).pptx
Brajeswar Paul
 
How to Store Data on the Odoo 17 Website
How to Store Data on the Odoo 17 WebsiteHow to Store Data on the Odoo 17 Website
How to Store Data on the Odoo 17 Website
Celine George
 

Recently uploaded (20)

Capitol Doctoral Presentation -June 2024v2.pptx
Capitol Doctoral Presentation -June 2024v2.pptxCapitol Doctoral Presentation -June 2024v2.pptx
Capitol Doctoral Presentation -June 2024v2.pptx
 
ENGLISH-7-CURRICULUM MAP- MATATAG CURRICULUM
ENGLISH-7-CURRICULUM MAP- MATATAG CURRICULUMENGLISH-7-CURRICULUM MAP- MATATAG CURRICULUM
ENGLISH-7-CURRICULUM MAP- MATATAG CURRICULUM
 
2024 KWL Back 2 School Summer Conference
2024 KWL Back 2 School Summer Conference2024 KWL Back 2 School Summer Conference
2024 KWL Back 2 School Summer Conference
 
How to Install Theme in the Odoo 17 ERP
How to  Install Theme in the Odoo 17 ERPHow to  Install Theme in the Odoo 17 ERP
How to Install Theme in the Odoo 17 ERP
 
The basics of sentences session 9pptx.pptx
The basics of sentences session 9pptx.pptxThe basics of sentences session 9pptx.pptx
The basics of sentences session 9pptx.pptx
 
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ..."DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
 
How to Add Colour Kanban Records in Odoo 17 Notebook
How to Add Colour Kanban Records in Odoo 17 NotebookHow to Add Colour Kanban Records in Odoo 17 Notebook
How to Add Colour Kanban Records in Odoo 17 Notebook
 
Split Shifts From Gantt View in the Odoo 17
Split Shifts From Gantt View in the  Odoo 17Split Shifts From Gantt View in the  Odoo 17
Split Shifts From Gantt View in the Odoo 17
 
Beyond the Advance Presentation for By the Book 9
Beyond the Advance Presentation for By the Book 9Beyond the Advance Presentation for By the Book 9
Beyond the Advance Presentation for By the Book 9
 
Traces of the Holocaust in our communities in Levice Sovakia and Constanta Ro...
Traces of the Holocaust in our communities in Levice Sovakia and Constanta Ro...Traces of the Holocaust in our communities in Levice Sovakia and Constanta Ro...
Traces of the Holocaust in our communities in Levice Sovakia and Constanta Ro...
 
DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...
DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...
DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...
 
L1 L2- NLC PPT for Grade 10 intervention
L1 L2- NLC PPT for Grade 10 interventionL1 L2- NLC PPT for Grade 10 intervention
L1 L2- NLC PPT for Grade 10 intervention
 
AI_in_HR_Presentation Part 1 2024 0703.pdf
AI_in_HR_Presentation Part 1 2024 0703.pdfAI_in_HR_Presentation Part 1 2024 0703.pdf
AI_in_HR_Presentation Part 1 2024 0703.pdf
 
The membership Module in the Odoo 17 ERP
The membership Module in the Odoo 17 ERPThe membership Module in the Odoo 17 ERP
The membership Module in the Odoo 17 ERP
 
NLC Grade 3.................................... ppt.pptx
NLC Grade 3.................................... ppt.pptxNLC Grade 3.................................... ppt.pptx
NLC Grade 3.................................... ppt.pptx
 
Is Email Marketing Really Effective In 2024?
Is Email Marketing Really Effective In 2024?Is Email Marketing Really Effective In 2024?
Is Email Marketing Really Effective In 2024?
 
Principles of Roods Approach!!!!!!!.pptx
Principles of Roods Approach!!!!!!!.pptxPrinciples of Roods Approach!!!!!!!.pptx
Principles of Roods Approach!!!!!!!.pptx
 
Delegation Inheritance in Odoo 17 and Its Use Cases
Delegation Inheritance in Odoo 17 and Its Use CasesDelegation Inheritance in Odoo 17 and Its Use Cases
Delegation Inheritance in Odoo 17 and Its Use Cases
 
Chapter-2-Era-of-One-party-Dominance-Class-12-Political-Science-Notes-2 (1).pptx
Chapter-2-Era-of-One-party-Dominance-Class-12-Political-Science-Notes-2 (1).pptxChapter-2-Era-of-One-party-Dominance-Class-12-Political-Science-Notes-2 (1).pptx
Chapter-2-Era-of-One-party-Dominance-Class-12-Political-Science-Notes-2 (1).pptx
 
How to Store Data on the Odoo 17 Website
How to Store Data on the Odoo 17 WebsiteHow to Store Data on the Odoo 17 Website
How to Store Data on the Odoo 17 Website
 

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