SlideShare a Scribd company logo
1 of 20
BIRLA INSTITUTE OF
TECHNOLOGY,MESRA JAIPUR
CAMPUS
Submitted By:
Apoorva Nagar
MCA/25013/18
“OPERATOR OVERLOADING”
OVERLOADING
• OPERATOR
OVERLOADING
BY APOORVA NAGAR
(MCA/25013/18)
&
• FUNCTION
OVERLOADING
BY MEGHAJ KR MALLICK
(MCA/25017/18)
OPERATOR
OVERLOADING
• In C++ operator overloading is a specific case of polymorphism,
where different operator have different implementations
depending upon their arguments.
• Overloading an operator is basically means assigning additional
operation to operator.
• C++ allows to define the behaviour of operators when applied
to objects of the class.
• Compiler generates appropriate code based on the manner in
which operator is used
OPERATORS FUNCTION
• Operators are overloaded by creating operators functions.
• Operator function defines the operations that are
overloaded operator will perform relative to the class upon
which it will work.
• syntax:
• To overload unary operator, operator function have single
argument.
• To overload binary operator, operator function have two
arguments.
• when an operator is used, the operands become the actual
arguments of the ‘function call’.
• operator function can be implemented using function
which can be:
1. Member function
2. Non-Member function
3. Friend function
• Operator overloading function can be a member function if
the Left operand is an Object of the class.
• Operator overloading function can be non-member
function if the left operand is not a object of the class.
• Operator overloading function can be friend function if it
needs access to private and protected members of class
#include<iostream>
using namespace std;
class Complex {
private:
int real, imag;
public:
Complex(int r = 0, int i =0)
{
real = r; imag = i;
}
void print()
{
cout << real << " + i" << imag << endl;
}
Complex operator + (Complex const &obj);
{
Complex res;
res.real=real+obj.real;
res.imag=imag+obj.imag;
return res ;
}
};
int main()
{
Complex c1(10, 5), c2(2, 4);
Complex c3 = c1 + c2; // An example call to "operator+"
c3.print();
return 0;
}
OUTPUT: 12+i9
OVERLOADABLE OPERATORS
NON-OVERLOADABLE OPERATORS
RESTRICTIONS ON OPERATOR OVERLOADING
• Precedence and associativity of an operator cannot be
changed.
• No new operators can be created.
• Number of operands cannot be changed.i.e. Unary
operators remains unary, binary operators remains binary.
• Meaning of operator should not be changed.i.e. + should
not mean subtraction.
ADVANTAGES OF OPERATOR OVERLOADING
• Extensibility: operator act differently depending on the
operands provided.
• Not limited to work with primitive data type.
• User can easily access the object to perform any operation.
THANK YOU!!!
FUNCTION OVERLOADING
BY
MEGHAJ KUMAR MALLICK
MCA/25017/18
1ST YEAR,2ND SEMESTER
DEFINITION
• Function Overloading is defined as the process
of having two or more function with the same
name, but different in parameters is known as
function overloading in C++.
• Function overloading is commonly used to
create several function of the same name that
perform similar task, but on different data type.
CONTINUED:
WHY OVERLOADING IS USEFUL ?
• Function overloading allows function that
conceptually perform the same task on object
of different type to be given same the same
name.
• It provides a convenient notation for
manipulating user defined object with
conventional operator.
EXAMPLE
• class printData {
• public:
• void print(int i) {
• cout << "Printing int: " << i << endl;
• }
• void print(double f) {
• cout << "Printing float: " << f << endl;
• }
• void print(char* c) {
• cout << "Printing character: " << c << endl;
• }
• };
EXAMPLE CONTINUED:
• When the above code is compiled and
executed, it produces the following result:
• Printing int: 5
• Printing float: 500.263
• Printing character: Hello C++
ADVANTAGES
• Overloaded methods give programmers the
flexibility to call a similar method for different
types of data.
• Function overloading is done for code
reusability, to save efforts, and also to save
memory.
Operator Overloading & Function Overloading

More Related Content

What's hot

Function overloading and overriding
Function overloading and overridingFunction overloading and overriding
Function overloading and overridingRajab Ali
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++Neeru Mittal
 
Introduction to array and string
Introduction to array and stringIntroduction to array and string
Introduction to array and stringMuntasirMuhit
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member FunctionsMOHIT AGARWAL
 
Operator overloading
Operator overloadingOperator overloading
Operator overloadingRamish Suleman
 
08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.pptTareq Hasan
 
Relational algebra ppt
Relational algebra pptRelational algebra ppt
Relational algebra pptGirdharRatne
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++HalaiHansaika
 
Control structure C++
Control structure C++Control structure C++
Control structure C++Anil Kumar
 
Inheritance in Java
Inheritance in JavaInheritance in Java
Inheritance in JavaTamanna Akter
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraintsmadhav bansal
 
Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2MOHIT TOMAR
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c languagetanmaymodi4
 
Control statements in c
Control statements in cControl statements in c
Control statements in cSathish Narayanan
 
Recursive Function
Recursive FunctionRecursive Function
Recursive FunctionKamal Acharya
 
SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)Sharad Dubey
 
Lecture 02 lexical analysis
Lecture 02 lexical analysisLecture 02 lexical analysis
Lecture 02 lexical analysisIffat Anjum
 

What's hot (20)

Function overloading and overriding
Function overloading and overridingFunction overloading and overriding
Function overloading and overriding
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
Introduction to array and string
Introduction to array and stringIntroduction to array and string
Introduction to array and string
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt
 
Relational algebra ppt
Relational algebra pptRelational algebra ppt
Relational algebra ppt
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
Control structure C++
Control structure C++Control structure C++
Control structure C++
 
Manipulators
ManipulatorsManipulators
Manipulators
 
Inheritance in Java
Inheritance in JavaInheritance in Java
Inheritance in Java
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Function overloading
Function overloadingFunction overloading
Function overloading
 
Recursive Function
Recursive FunctionRecursive Function
Recursive Function
 
SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
 
Lecture 02 lexical analysis
Lecture 02 lexical analysisLecture 02 lexical analysis
Lecture 02 lexical analysis
 

Similar to Operator Overloading & Function Overloading

OPERATOR OVERLOADING IN C++
OPERATOR OVERLOADING IN C++OPERATOR OVERLOADING IN C++
OPERATOR OVERLOADING IN C++Aabha Tiwari
 
OOPS-Seminar.pdf
OOPS-Seminar.pdfOOPS-Seminar.pdf
OOPS-Seminar.pdfRithiga6
 
NIKUL SURANI
NIKUL SURANINIKUL SURANI
NIKUL SURANINikul4470
 
OOP_UnitIII.pdf
OOP_UnitIII.pdfOOP_UnitIII.pdf
OOP_UnitIII.pdfSuyogSabale1
 
Oop05 6
Oop05 6Oop05 6
Oop05 6schwaa
 
Polymorphism
PolymorphismPolymorphism
PolymorphismAmir Ali
 
Operator Overloading in C++
Operator Overloading in C++Operator Overloading in C++
Operator Overloading in C++Mohammed Sikander
 
Operator overloadng
Operator overloadngOperator overloadng
Operator overloadngpreethalal
 
11.C++Polymorphism [Autosaved].pptx
11.C++Polymorphism [Autosaved].pptx11.C++Polymorphism [Autosaved].pptx
11.C++Polymorphism [Autosaved].pptxAtharvPotdar2
 
Polymorphism
PolymorphismPolymorphism
Polymorphismsana younas
 
Operator overloading and type conversions
Operator overloading and type conversionsOperator overloading and type conversions
Operator overloading and type conversionsAmogh Kalyanshetti
 
An evaluation of FaaS platforms as a foundation for serverless big data proce...
An evaluation of FaaS platforms as a foundation for serverless big data proce...An evaluation of FaaS platforms as a foundation for serverless big data proce...
An evaluation of FaaS platforms as a foundation for serverless big data proce...Mohamed Samir
 
POLYMORPHISM
POLYMORPHISMPOLYMORPHISM
POLYMORPHISMRamya850883
 
Polymorphism 140527082302-phpapp01
Polymorphism 140527082302-phpapp01Polymorphism 140527082302-phpapp01
Polymorphism 140527082302-phpapp01Engr.Tazeen Ahmed
 
Programming Sessions KU Leuven - Session 02
Programming Sessions KU Leuven - Session 02Programming Sessions KU Leuven - Session 02
Programming Sessions KU Leuven - Session 02Rafael Camacho Dejay
 
B.sc CSIT 2nd semester C++ Unit4
B.sc CSIT  2nd semester C++ Unit4B.sc CSIT  2nd semester C++ Unit4
B.sc CSIT 2nd semester C++ Unit4Tekendra Nath Yogi
 

Similar to Operator Overloading & Function Overloading (20)

OPERATOR OVERLOADING IN C++
OPERATOR OVERLOADING IN C++OPERATOR OVERLOADING IN C++
OPERATOR OVERLOADING IN C++
 
OOPS-Seminar.pdf
OOPS-Seminar.pdfOOPS-Seminar.pdf
OOPS-Seminar.pdf
 
c++
c++c++
c++
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
NIKUL SURANI
NIKUL SURANINIKUL SURANI
NIKUL SURANI
 
OOP_UnitIII.pdf
OOP_UnitIII.pdfOOP_UnitIII.pdf
OOP_UnitIII.pdf
 
operator overloading in C++
operator overloading in C++operator overloading in C++
operator overloading in C++
 
Oop05 6
Oop05 6Oop05 6
Oop05 6
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Operator Overloading in C++
Operator Overloading in C++Operator Overloading in C++
Operator Overloading in C++
 
Operator overloadng
Operator overloadngOperator overloadng
Operator overloadng
 
11.C++Polymorphism [Autosaved].pptx
11.C++Polymorphism [Autosaved].pptx11.C++Polymorphism [Autosaved].pptx
11.C++Polymorphism [Autosaved].pptx
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Operator overloading and type conversions
Operator overloading and type conversionsOperator overloading and type conversions
Operator overloading and type conversions
 
An evaluation of FaaS platforms as a foundation for serverless big data proce...
An evaluation of FaaS platforms as a foundation for serverless big data proce...An evaluation of FaaS platforms as a foundation for serverless big data proce...
An evaluation of FaaS platforms as a foundation for serverless big data proce...
 
POLYMORPHISM
POLYMORPHISMPOLYMORPHISM
POLYMORPHISM
 
Virtual Function
Virtual FunctionVirtual Function
Virtual Function
 
Polymorphism 140527082302-phpapp01
Polymorphism 140527082302-phpapp01Polymorphism 140527082302-phpapp01
Polymorphism 140527082302-phpapp01
 
Programming Sessions KU Leuven - Session 02
Programming Sessions KU Leuven - Session 02Programming Sessions KU Leuven - Session 02
Programming Sessions KU Leuven - Session 02
 
B.sc CSIT 2nd semester C++ Unit4
B.sc CSIT  2nd semester C++ Unit4B.sc CSIT  2nd semester C++ Unit4
B.sc CSIT 2nd semester C++ Unit4
 

More from Meghaj Mallick

24 partial-orderings
24 partial-orderings24 partial-orderings
24 partial-orderingsMeghaj Mallick
 
PORTFOLIO BY USING HTML & CSS
PORTFOLIO BY USING HTML & CSSPORTFOLIO BY USING HTML & CSS
PORTFOLIO BY USING HTML & CSSMeghaj Mallick
 
Introduction to Software Testing
Introduction to Software TestingIntroduction to Software Testing
Introduction to Software TestingMeghaj Mallick
 
Introduction to System Programming
Introduction to System ProgrammingIntroduction to System Programming
Introduction to System ProgrammingMeghaj Mallick
 
Icons, Image & Multimedia
Icons, Image & MultimediaIcons, Image & Multimedia
Icons, Image & MultimediaMeghaj Mallick
 
Project Tracking & SPC
Project Tracking & SPCProject Tracking & SPC
Project Tracking & SPCMeghaj Mallick
 
Peephole Optimization
Peephole OptimizationPeephole Optimization
Peephole OptimizationMeghaj Mallick
 
Routing in MANET
Routing in MANETRouting in MANET
Routing in MANETMeghaj Mallick
 
Macro assembler
 Macro assembler Macro assembler
Macro assemblerMeghaj Mallick
 
Architecture and security in Vanet PPT
Architecture and security in Vanet PPTArchitecture and security in Vanet PPT
Architecture and security in Vanet PPTMeghaj Mallick
 
Design Model & User Interface Design in Software Engineering
Design Model & User Interface Design in Software EngineeringDesign Model & User Interface Design in Software Engineering
Design Model & User Interface Design in Software EngineeringMeghaj Mallick
 
Text Mining of Twitter in Data Mining
Text Mining of Twitter in Data MiningText Mining of Twitter in Data Mining
Text Mining of Twitter in Data MiningMeghaj Mallick
 
DFS & BFS in Computer Algorithm
DFS & BFS in Computer AlgorithmDFS & BFS in Computer Algorithm
DFS & BFS in Computer AlgorithmMeghaj Mallick
 
Software Development Method
Software Development MethodSoftware Development Method
Software Development MethodMeghaj Mallick
 
Secant method in Numerical & Statistical Method
Secant method in Numerical & Statistical MethodSecant method in Numerical & Statistical Method
Secant method in Numerical & Statistical MethodMeghaj Mallick
 
Motivation in Organization
Motivation in OrganizationMotivation in Organization
Motivation in OrganizationMeghaj Mallick
 
Communication Skill
Communication SkillCommunication Skill
Communication SkillMeghaj Mallick
 
Partial-Orderings in Discrete Mathematics
 Partial-Orderings in Discrete Mathematics Partial-Orderings in Discrete Mathematics
Partial-Orderings in Discrete MathematicsMeghaj Mallick
 
Hashing In Data Structure
Hashing In Data Structure Hashing In Data Structure
Hashing In Data Structure Meghaj Mallick
 

More from Meghaj Mallick (20)

24 partial-orderings
24 partial-orderings24 partial-orderings
24 partial-orderings
 
PORTFOLIO BY USING HTML & CSS
PORTFOLIO BY USING HTML & CSSPORTFOLIO BY USING HTML & CSS
PORTFOLIO BY USING HTML & CSS
 
Introduction to Software Testing
Introduction to Software TestingIntroduction to Software Testing
Introduction to Software Testing
 
Introduction to System Programming
Introduction to System ProgrammingIntroduction to System Programming
Introduction to System Programming
 
MACRO ASSEBLER
MACRO ASSEBLERMACRO ASSEBLER
MACRO ASSEBLER
 
Icons, Image & Multimedia
Icons, Image & MultimediaIcons, Image & Multimedia
Icons, Image & Multimedia
 
Project Tracking & SPC
Project Tracking & SPCProject Tracking & SPC
Project Tracking & SPC
 
Peephole Optimization
Peephole OptimizationPeephole Optimization
Peephole Optimization
 
Routing in MANET
Routing in MANETRouting in MANET
Routing in MANET
 
Macro assembler
 Macro assembler Macro assembler
Macro assembler
 
Architecture and security in Vanet PPT
Architecture and security in Vanet PPTArchitecture and security in Vanet PPT
Architecture and security in Vanet PPT
 
Design Model & User Interface Design in Software Engineering
Design Model & User Interface Design in Software EngineeringDesign Model & User Interface Design in Software Engineering
Design Model & User Interface Design in Software Engineering
 
Text Mining of Twitter in Data Mining
Text Mining of Twitter in Data MiningText Mining of Twitter in Data Mining
Text Mining of Twitter in Data Mining
 
DFS & BFS in Computer Algorithm
DFS & BFS in Computer AlgorithmDFS & BFS in Computer Algorithm
DFS & BFS in Computer Algorithm
 
Software Development Method
Software Development MethodSoftware Development Method
Software Development Method
 
Secant method in Numerical & Statistical Method
Secant method in Numerical & Statistical MethodSecant method in Numerical & Statistical Method
Secant method in Numerical & Statistical Method
 
Motivation in Organization
Motivation in OrganizationMotivation in Organization
Motivation in Organization
 
Communication Skill
Communication SkillCommunication Skill
Communication Skill
 
Partial-Orderings in Discrete Mathematics
 Partial-Orderings in Discrete Mathematics Partial-Orderings in Discrete Mathematics
Partial-Orderings in Discrete Mathematics
 
Hashing In Data Structure
Hashing In Data Structure Hashing In Data Structure
Hashing In Data Structure
 

Recently uploaded

Microsoft Copilot AI for Everyone - created by AI
Microsoft Copilot AI for Everyone - created by AIMicrosoft Copilot AI for Everyone - created by AI
Microsoft Copilot AI for Everyone - created by AITatiana Gurgel
 
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfOpen Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfhenrik385807
 
LANDMARKS AND MONUMENTS IN NIGERIA.pptx
LANDMARKS  AND MONUMENTS IN NIGERIA.pptxLANDMARKS  AND MONUMENTS IN NIGERIA.pptx
LANDMARKS AND MONUMENTS IN NIGERIA.pptxBasil Achie
 
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...NETWAYS
 
WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )
WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )
WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )Pooja Nehwal
 
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur fĂźr Container und Kubern...
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur fĂźr Container und Kubern...OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur fĂźr Container und Kubern...
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur fĂźr Container und Kubern...NETWAYS
 
OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...
OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...
OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...NETWAYS
 
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...NETWAYS
 
Russian Call Girls in Kolkata Vaishnavi 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Vaishnavi 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Vaishnavi 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Vaishnavi 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...henrik385807
 
Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...
Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...
Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...Kayode Fayemi
 
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSimulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSebastiano Panichella
 
AndrĂŠs RamĂ­rez Gossler, Facundo Schinnea - eCommerce Day Chile 2024
AndrĂŠs RamĂ­rez Gossler, Facundo Schinnea - eCommerce Day Chile 2024AndrĂŠs RamĂ­rez Gossler, Facundo Schinnea - eCommerce Day Chile 2024
AndrĂŠs RamĂ­rez Gossler, Facundo Schinnea - eCommerce Day Chile 2024eCommerce Institute
 
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...NETWAYS
 
The 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringThe 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringSebastiano Panichella
 
SBFT Tool Competition 2024 - CPS-UAV Test Case Generation Track
SBFT Tool Competition 2024 - CPS-UAV Test Case Generation TrackSBFT Tool Competition 2024 - CPS-UAV Test Case Generation Track
SBFT Tool Competition 2024 - CPS-UAV Test Case Generation TrackSebastiano Panichella
 
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝soniya singh
 
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdfCTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdfhenrik385807
 
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779Night 7k Call Girls Noida Sector 128 Call Me: 8448380779
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779Delhi Call girls
 
SBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSebastiano Panichella
 

Recently uploaded (20)

Microsoft Copilot AI for Everyone - created by AI
Microsoft Copilot AI for Everyone - created by AIMicrosoft Copilot AI for Everyone - created by AI
Microsoft Copilot AI for Everyone - created by AI
 
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfOpen Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
 
LANDMARKS AND MONUMENTS IN NIGERIA.pptx
LANDMARKS  AND MONUMENTS IN NIGERIA.pptxLANDMARKS  AND MONUMENTS IN NIGERIA.pptx
LANDMARKS AND MONUMENTS IN NIGERIA.pptx
 
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
 
WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )
WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )
WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )
 
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur fĂźr Container und Kubern...
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur fĂźr Container und Kubern...OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur fĂźr Container und Kubern...
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur fĂźr Container und Kubern...
 
OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...
OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...
OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...
 
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
 
Russian Call Girls in Kolkata Vaishnavi 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Vaishnavi 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Vaishnavi 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Vaishnavi 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
 
Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...
Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...
Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...
 
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSimulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
 
AndrĂŠs RamĂ­rez Gossler, Facundo Schinnea - eCommerce Day Chile 2024
AndrĂŠs RamĂ­rez Gossler, Facundo Schinnea - eCommerce Day Chile 2024AndrĂŠs RamĂ­rez Gossler, Facundo Schinnea - eCommerce Day Chile 2024
AndrĂŠs RamĂ­rez Gossler, Facundo Schinnea - eCommerce Day Chile 2024
 
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
 
The 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringThe 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software Engineering
 
SBFT Tool Competition 2024 - CPS-UAV Test Case Generation Track
SBFT Tool Competition 2024 - CPS-UAV Test Case Generation TrackSBFT Tool Competition 2024 - CPS-UAV Test Case Generation Track
SBFT Tool Competition 2024 - CPS-UAV Test Case Generation Track
 
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝
 
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdfCTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
 
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779Night 7k Call Girls Noida Sector 128 Call Me: 8448380779
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779
 
SBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation Track
 

Operator Overloading & Function Overloading

  • 1. BIRLA INSTITUTE OF TECHNOLOGY,MESRA JAIPUR CAMPUS Submitted By: Apoorva Nagar MCA/25013/18 “OPERATOR OVERLOADING”
  • 2. OVERLOADING • OPERATOR OVERLOADING BY APOORVA NAGAR (MCA/25013/18) & • FUNCTION OVERLOADING BY MEGHAJ KR MALLICK (MCA/25017/18)
  • 4. • In C++ operator overloading is a specific case of polymorphism, where different operator have different implementations depending upon their arguments. • Overloading an operator is basically means assigning additional operation to operator. • C++ allows to define the behaviour of operators when applied to objects of the class. • Compiler generates appropriate code based on the manner in which operator is used
  • 5. OPERATORS FUNCTION • Operators are overloaded by creating operators functions. • Operator function defines the operations that are overloaded operator will perform relative to the class upon which it will work. • syntax:
  • 6. • To overload unary operator, operator function have single argument. • To overload binary operator, operator function have two arguments. • when an operator is used, the operands become the actual arguments of the ‘function call’. • operator function can be implemented using function which can be: 1. Member function 2. Non-Member function 3. Friend function
  • 7. • Operator overloading function can be a member function if the Left operand is an Object of the class. • Operator overloading function can be non-member function if the left operand is not a object of the class. • Operator overloading function can be friend function if it needs access to private and protected members of class
  • 8. #include<iostream> using namespace std; class Complex { private: int real, imag; public: Complex(int r = 0, int i =0) { real = r; imag = i; } void print() { cout << real << " + i" << imag << endl; } Complex operator + (Complex const &obj); { Complex res; res.real=real+obj.real; res.imag=imag+obj.imag; return res ; } }; int main() { Complex c1(10, 5), c2(2, 4); Complex c3 = c1 + c2; // An example call to "operator+" c3.print(); return 0; } OUTPUT: 12+i9
  • 10. RESTRICTIONS ON OPERATOR OVERLOADING • Precedence and associativity of an operator cannot be changed. • No new operators can be created. • Number of operands cannot be changed.i.e. Unary operators remains unary, binary operators remains binary. • Meaning of operator should not be changed.i.e. + should not mean subtraction.
  • 11. ADVANTAGES OF OPERATOR OVERLOADING • Extensibility: operator act differently depending on the operands provided. • Not limited to work with primitive data type. • User can easily access the object to perform any operation.
  • 13. FUNCTION OVERLOADING BY MEGHAJ KUMAR MALLICK MCA/25017/18 1ST YEAR,2ND SEMESTER
  • 14. DEFINITION • Function Overloading is defined as the process of having two or more function with the same name, but different in parameters is known as function overloading in C++. • Function overloading is commonly used to create several function of the same name that perform similar task, but on different data type.
  • 16. WHY OVERLOADING IS USEFUL ? • Function overloading allows function that conceptually perform the same task on object of different type to be given same the same name. • It provides a convenient notation for manipulating user defined object with conventional operator.
  • 17. EXAMPLE • class printData { • public: • void print(int i) { • cout << "Printing int: " << i << endl; • } • void print(double f) { • cout << "Printing float: " << f << endl; • } • void print(char* c) { • cout << "Printing character: " << c << endl; • } • };
  • 18. EXAMPLE CONTINUED: • When the above code is compiled and executed, it produces the following result: • Printing int: 5 • Printing float: 500.263 • Printing character: Hello C++
  • 19. ADVANTAGES • Overloaded methods give programmers the flexibility to call a similar method for different types of data. • Function overloading is done for code reusability, to save efforts, and also to save memory.