SlideShare a Scribd company logo
8
Most read
9
Most read
10
Most read
G.BALAJI MCA, M.Tech.,
Assistant Professor of Computer Science
Vivekananda College, Madurai
Operator Overloading:
 Operator – It is a symbol that indicates an operation.
Arithmetic operators are + (add two numbers), - (subtract two
numbers), * ( Multiply two numbers), / ( Divide between two
numbers).
 At now, we will take an Addition ‘+’ Sign, its use of ‘+’ sign
is
5+5=10
2.5+2.5=5
 Operator Overloading means multiple functions or multiple
jobs. In operator overloading the ‘+’ sign use of add the two
objects.
 One of C++’s great features is its extensibility, Operator
Overloading is major functionality related to extensibility.
 In C++, most of operators can be overloaded so that they can
perform special operations relative to the classes you create.
 For Example, ‘+’ operator can be overloaded to perform an
operation of string concatenation along with its pre-defined
job of adding two numeric values.
 When an operator is overloaded, none of its original meaning
will be lost.
 After overloading the appropriate operators, you can use
C++’s built in data types.
 Unary Operator
- Operators attached to a single operand.
(-a, +a, --a, ++a, a--, a++)
 Binary Operator
- Operators attached to two operand.
(a-b, a+b, a*b, a/b, a%b, a>b, a<b )
return-type class-name:: operator op(arg-list)
{
function body
}
EXPLANATION
 return type – It is the type of value returned by the specified
operation.
 op - It is the operator being overloaded. It may be unary or
binary operator. It is preceded by the keyword operator.
 operator op - It is the function name, Where operator is a
keyword.
INTRODUCTION
 In Binary operator overloading function, there should be one
argument to be passed.
 It is overloading of an operator operating on two operands.
#include<iostream>
class multiply
{
int first,second;
public:
void getdata(int a,int b)
{
first=a;
second=b;
}
Contd...,
void display()
{
cout<<“first=“<<first<<“second=“<<secon<<endl;
}
multiply operator *(multiply c);
};
void multiply::operator *(multiply c)
{
multiply temp;
temp.first=first*c.first;
temp.second=second*c.second;
return temp;
}
Contd..,
int main()
{
multiply obj1,obj2,obj3;
obj1.getdata(15,20);
obj2.getdata(3,45);
obj3=obj1*obj2;
obj3.display();
return 0;
}
Output:
45
900

More Related Content

What's hot (20)

PPTX
Type conversion
PreethaPreetha5
 
PPTX
Static Data Members and Member Functions
MOHIT AGARWAL
 
PPTX
Fundamentals of OOP (Object Oriented Programming)
MD Sulaiman
 
PPTX
Classes, objects in JAVA
Abhilash Nair
 
PPT
C program
AJAL A J
 
PPTX
Destructors
DeepikaT13
 
PPTX
Stream classes in C++
Shyam Gupta
 
PPTX
Functions in C
Kamal Acharya
 
PPTX
Constructors and Destructor in C++
International Institute of Information Technology (I²IT)
 
PDF
Introduction to oops concepts
Nilesh Dalvi
 
PDF
Operator overloading C++
Lahiru Dilshan
 
PPTX
Presentation on Function in C Programming
Shuvongkor Barman
 
PPTX
C functions
University of Potsdam
 
PPTX
Data Types and Variables In C Programming
Kamal Acharya
 
PPTX
Function overloading and overriding
Rajab Ali
 
PDF
Managing I/O in c++
Pranali Chaudhari
 
PPT
Constants in C Programming
programming9
 
PPTX
Object Oriented Programming using C++(UNIT 1)
Dr. SURBHI SAROHA
 
PPTX
Introduction Of C++
Sangharsh agarwal
 
PDF
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
SowmyaJyothi3
 
Type conversion
PreethaPreetha5
 
Static Data Members and Member Functions
MOHIT AGARWAL
 
Fundamentals of OOP (Object Oriented Programming)
MD Sulaiman
 
Classes, objects in JAVA
Abhilash Nair
 
C program
AJAL A J
 
Destructors
DeepikaT13
 
Stream classes in C++
Shyam Gupta
 
Functions in C
Kamal Acharya
 
Introduction to oops concepts
Nilesh Dalvi
 
Operator overloading C++
Lahiru Dilshan
 
Presentation on Function in C Programming
Shuvongkor Barman
 
Data Types and Variables In C Programming
Kamal Acharya
 
Function overloading and overriding
Rajab Ali
 
Managing I/O in c++
Pranali Chaudhari
 
Constants in C Programming
programming9
 
Object Oriented Programming using C++(UNIT 1)
Dr. SURBHI SAROHA
 
Introduction Of C++
Sangharsh agarwal
 
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
SowmyaJyothi3
 

Similar to Binary operator overloading (20)

PPT
Unary operator overloading
BalajiGovindan5
 
PPT
Operator overloading in C++
BalajiGovindan5
 
PDF
OOPS-Seminar.pdf
Rithiga6
 
PPTX
Operator overloading
Burhan Ahmed
 
PPTX
Oops
ankush_kumar
 
PPTX
Week7a.pptx
NasirAli233814
 
PPT
Lec 26.27-operator overloading
Princess Sam
 
PPTX
Operator overloading
Garima Singh Makhija
 
PPTX
OPERATOR OVERLOADING IN C++
Aabha Tiwari
 
PPTX
operator overloading
Nishant Joshi
 
PPT
Lec 28 - operator overloading
Princess Sam
 
PPTX
Operator overloading
ramya marichamy
 
PPTX
Object Oriented Programming using C++: Ch08 Operator Overloading.pptx
RashidFaridChishti
 
PDF
M11 operator overloading and type conversion
NabeelaNousheen
 
PPTX
Operator overloadng
preethalal
 
PDF
22 scheme OOPs with C++ BCS306B_module3.pdf
sindhus795217
 
PDF
Object Oriented Programming using C++ - Part 3
University College of Engineering Kakinada, JNTUK - Kakinada, India
 
PPTX
OOP Week 4 Lecture 1.pptx
whoiam36
 
PDF
Operator overloading
Pranali Chaudhari
 
PDF
Ch-4-Operator Overloading.pdf
esuEthopi
 
Unary operator overloading
BalajiGovindan5
 
Operator overloading in C++
BalajiGovindan5
 
OOPS-Seminar.pdf
Rithiga6
 
Operator overloading
Burhan Ahmed
 
Week7a.pptx
NasirAli233814
 
Lec 26.27-operator overloading
Princess Sam
 
Operator overloading
Garima Singh Makhija
 
OPERATOR OVERLOADING IN C++
Aabha Tiwari
 
operator overloading
Nishant Joshi
 
Lec 28 - operator overloading
Princess Sam
 
Operator overloading
ramya marichamy
 
Object Oriented Programming using C++: Ch08 Operator Overloading.pptx
RashidFaridChishti
 
M11 operator overloading and type conversion
NabeelaNousheen
 
Operator overloadng
preethalal
 
22 scheme OOPs with C++ BCS306B_module3.pdf
sindhus795217
 
Object Oriented Programming using C++ - Part 3
University College of Engineering Kakinada, JNTUK - Kakinada, India
 
OOP Week 4 Lecture 1.pptx
whoiam36
 
Operator overloading
Pranali Chaudhari
 
Ch-4-Operator Overloading.pdf
esuEthopi
 
Ad

Recently uploaded (20)

PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PDF
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
community health nursing question paper 2.pdf
Prince kumar
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Ad

Binary operator overloading

  • 1. G.BALAJI MCA, M.Tech., Assistant Professor of Computer Science Vivekananda College, Madurai
  • 2. Operator Overloading:  Operator – It is a symbol that indicates an operation. Arithmetic operators are + (add two numbers), - (subtract two numbers), * ( Multiply two numbers), / ( Divide between two numbers).  At now, we will take an Addition ‘+’ Sign, its use of ‘+’ sign is 5+5=10 2.5+2.5=5
  • 3.  Operator Overloading means multiple functions or multiple jobs. In operator overloading the ‘+’ sign use of add the two objects.  One of C++’s great features is its extensibility, Operator Overloading is major functionality related to extensibility.  In C++, most of operators can be overloaded so that they can perform special operations relative to the classes you create.
  • 4.  For Example, ‘+’ operator can be overloaded to perform an operation of string concatenation along with its pre-defined job of adding two numeric values.  When an operator is overloaded, none of its original meaning will be lost.  After overloading the appropriate operators, you can use C++’s built in data types.
  • 5.  Unary Operator - Operators attached to a single operand. (-a, +a, --a, ++a, a--, a++)  Binary Operator - Operators attached to two operand. (a-b, a+b, a*b, a/b, a%b, a>b, a<b )
  • 6. return-type class-name:: operator op(arg-list) { function body } EXPLANATION  return type – It is the type of value returned by the specified operation.  op - It is the operator being overloaded. It may be unary or binary operator. It is preceded by the keyword operator.  operator op - It is the function name, Where operator is a keyword.
  • 7. INTRODUCTION  In Binary operator overloading function, there should be one argument to be passed.  It is overloading of an operator operating on two operands.
  • 8. #include<iostream> class multiply { int first,second; public: void getdata(int a,int b) { first=a; second=b; } Contd...,
  • 9. void display() { cout<<“first=“<<first<<“second=“<<secon<<endl; } multiply operator *(multiply c); }; void multiply::operator *(multiply c) { multiply temp; temp.first=first*c.first; temp.second=second*c.second; return temp; } Contd..,