SlideShare ist ein Scribd-Unternehmen logo
1 von 18
Downloaden Sie, um offline zu lesen
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 1
Haresh Jaiswal
Rising Technologies, Jalna.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 2
Introduction
 Operator overloading is an important branch of Polymorphism in
C++.
Polymorphism
RuntimeCompile Time
Function
Overloading
Operator
Overloading
Virtual
Functions
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 3
Introduction
 In simple words, overloading an operator means assigning
additional operation or job to it; relative to a specific class (user
defined type).
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 4
Introduction
 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.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 5
Introduction
 After overloading the appropriate operators, you can use objects
in expressions in just the same way you use C++'s built-in data
types.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 6
Introduction
 Consider following piece of code. Considering the + operator is
overloaded in such a way with class String that it will concatenate
two string objects.
int main()
{
int n1 = 10, n2 = 20, n2;
String s1 = “Rising”, s2=“Tech”, s3;
n3 = n1 + n2; // addition
s3 = s1 + s2; // concatenation
}
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 7
Overloading Operators
 Operators come in three flavours:
 Unary (++, --)
 Binary (+, -)
 Ternary (?:)
 You are free to overload most of the built-in operators, but you
cannot create new operators of your own.
 Therefore, although you can give your class an increment
operator (++), you cannot create a squared operator.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 8
Overloading Operators
 You can overload these operators to do anything you want, but it
is a good programming practice for them to make sense.
 That means you can have the ++ operator to decrement, but it
would make no sense to do so.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 9
Operators Function
 Operators are overloaded by creating operator functions
 An operator function defines the operations that the overloaded
operator will perform relative to the class upon which it will
work.
 An operator function is created using the keyword operator
 Operator functions can be either
 Member function of a class or
 Non-member function (Mostly Friend Functions)
 The way operator functions are written differs between member
and non-member functions.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 10
Member Operators Function
 A member operator function for binary operators
RetType ClassName::operator#(arg-list)
{
// operations
}
 Often, operator functions returns an object of the class they
operate on, but ret-type can be any valid type.
 The # is a placeholder. When you create an operator function,
substitute the operator for the #.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 11
Member Operators Function
RetType ClassName::operator#(arg-list)
{
// operations
}
 For example, if you are overloading the + operator, use
operator+
 While overloading binary operators using member function,
the arg-list will contain one parameter.
 A member operator function for binary operators
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 12
Member Operators Function
 A member operator function for Unary operators
RetType ClassName::operator#()
{
// operations
}
 While overloading an unary operator, arg-list will be empty.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 13
Friend Operators Function
 Instead of Member function, you can define operator functions
that will be friend to the class you have created.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 14
Friend Operators Function
 A friend operator function for binary operators
RetType operator#(arg-list)
{
// operations
}
 While overloading a binary operator using friend function;
argument list must take 2 arguments, one of them must be of
user defined type.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 15
Friend Operators Function
 A friend operator function for Unary operators
RetType operator#(arg-list)
{
// operations
}
 While overloading an unary operator using friend function;
argument list must have 1 argument as reference to the object.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 16
Overloading Operators : Rules
 You can overload virtually any c++ operator, but you cannot
create your own set of operators.
 You cannot change any operators precedence.
 You cannot change syntax to use an operator.
 You cannot alter the pre-defined job performed by any operator,
that means you cannot overload + operator in such a way to
perform subtraction of two integers.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 17
Overloading Operators : Rules
 You can overload most of Unary and Binary Operators, but you
cannot overload the ternary operator (?:)
 Binary as well as Unary operators can be overloaded by both
Approaches
 Member Functions Approach
 Friend Function Approach
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 18
Overloading Binary Operators
 While overloading binary operators; at least one of its operand
should be of user defined types.
 The operator function must return an object.

Weitere ähnliche Inhalte

Was ist angesagt?

Virtual base class
Virtual base classVirtual base class
Virtual base class
Tech_MX
 
Inline function
Inline functionInline function
Inline function
Tech_MX
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
Tech_MX
 

Was ist angesagt? (20)

Unary operator overloading
Unary operator overloadingUnary operator overloading
Unary operator overloading
 
Method overriding
Method overridingMethod overriding
Method overriding
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
String.ppt
String.pptString.ppt
String.ppt
 
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
 
Operator overloading C++
Operator overloading C++Operator overloading C++
Operator overloading C++
 
Polymorphism In c++
Polymorphism In c++Polymorphism In c++
Polymorphism In c++
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
 
Friend function
Friend functionFriend function
Friend function
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
 
Virtual base class
Virtual base classVirtual base class
Virtual base class
 
Friend function in c++
Friend function in c++ Friend function in c++
Friend function in c++
 
Inline function
Inline functionInline function
Inline function
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
 
Polymorphism In Java
Polymorphism In JavaPolymorphism In Java
Polymorphism In Java
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
C++ oop
C++ oopC++ oop
C++ oop
 
Constructor and destructor
Constructor  and  destructor Constructor  and  destructor
Constructor and destructor
 
Oops concept on c#
Oops concept on c#Oops concept on c#
Oops concept on c#
 

Andere mochten auch

Operator overloading
Operator overloadingOperator overloading
Operator overloading
Kumar
 
Lec 26.27-operator overloading
Lec 26.27-operator overloadingLec 26.27-operator overloading
Lec 26.27-operator overloading
Princess Sam
 
Presentation on overloading
Presentation on overloading Presentation on overloading
Presentation on overloading
Charndeep Sekhon
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
Kamal Acharya
 
Operator overloadng
Operator overloadngOperator overloadng
Operator overloadng
preethalal
 
Java classes and objects interview questions
Java classes and objects interview questionsJava classes and objects interview questions
Java classes and objects interview questions
Dhivyashree Selvarajtnkpm
 

Andere mochten auch (20)

Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Lec 26.27-operator overloading
Lec 26.27-operator overloadingLec 26.27-operator overloading
Lec 26.27-operator overloading
 
operator overloading in c++
operator overloading in c++operator overloading in c++
operator overloading in c++
 
Presentation on overloading
Presentation on overloading Presentation on overloading
Presentation on overloading
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Bca 2nd sem u-4 operator overloading
Bca 2nd sem u-4 operator overloadingBca 2nd sem u-4 operator overloading
Bca 2nd sem u-4 operator overloading
 
Operator overloadng
Operator overloadngOperator overloadng
Operator overloadng
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Abstract Base Class and Polymorphism in C++
Abstract Base Class and Polymorphism in C++Abstract Base Class and Polymorphism in C++
Abstract Base Class and Polymorphism in C++
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Function Overlaoding
Function OverlaodingFunction Overlaoding
Function Overlaoding
 
Function overloading
Function overloadingFunction overloading
Function overloading
 
Function overloading
Function overloadingFunction overloading
Function overloading
 
Java classes and objects interview questions
Java classes and objects interview questionsJava classes and objects interview questions
Java classes and objects interview questions
 
Operator overloading
Operator overloading Operator overloading
Operator overloading
 
cpp input & output system basics
cpp input & output system basicscpp input & output system basics
cpp input & output system basics
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
operator overloading
operator overloadingoperator overloading
operator overloading
 
2CPP17 - File IO
2CPP17 - File IO2CPP17 - File IO
2CPP17 - File IO
 
Operator overloading in C++
Operator overloading in C++Operator overloading in C++
Operator overloading in C++
 

Ähnlich wie 06. operator overloading

379008-rc217-functionalprogramming
379008-rc217-functionalprogramming379008-rc217-functionalprogramming
379008-rc217-functionalprogramming
Luis Atencio
 
04. constructor & destructor
04. constructor & destructor04. constructor & destructor
04. constructor & destructor
Haresh Jaiswal
 
Lec 28 - operator overloading
Lec 28 - operator overloadingLec 28 - operator overloading
Lec 28 - operator overloading
Princess Sam
 

Ähnlich wie 06. operator overloading (20)

02. functions & introduction to class
02. functions & introduction to class02. functions & introduction to class
02. functions & introduction to class
 
379008-rc217-functionalprogramming
379008-rc217-functionalprogramming379008-rc217-functionalprogramming
379008-rc217-functionalprogramming
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
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
 
Operator overloading and type conversions
Operator overloading and type conversionsOperator overloading and type conversions
Operator overloading and type conversions
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Function overloading
Function overloadingFunction overloading
Function overloading
 
Functional Programming With Lambdas and Streams in JDK8
 Functional Programming With Lambdas and Streams in JDK8 Functional Programming With Lambdas and Streams in JDK8
Functional Programming With Lambdas and Streams in JDK8
 
operator overloading in C++
operator overloading in C++operator overloading in C++
operator overloading in C++
 
Oops
OopsOops
Oops
 
Unary operator overloading
Unary operator overloadingUnary operator overloading
Unary operator overloading
 
04. constructor & destructor
04. constructor & destructor04. constructor & destructor
04. constructor & destructor
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Lec 28 - operator overloading
Lec 28 - operator overloadingLec 28 - operator overloading
Lec 28 - operator overloading
 
How easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performanceHow easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performance
 
Graal and Truffle: One VM to Rule Them All
Graal and Truffle: One VM to Rule Them AllGraal and Truffle: One VM to Rule Them All
Graal and Truffle: One VM to Rule Them All
 
Binary operator overloading
Binary operator overloadingBinary operator overloading
Binary operator overloading
 

Kürzlich hochgeladen

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Kürzlich hochgeladen (20)

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 

06. operator overloading

  • 1. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 1 Haresh Jaiswal Rising Technologies, Jalna.
  • 2. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 2 Introduction  Operator overloading is an important branch of Polymorphism in C++. Polymorphism RuntimeCompile Time Function Overloading Operator Overloading Virtual Functions
  • 3. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 3 Introduction  In simple words, overloading an operator means assigning additional operation or job to it; relative to a specific class (user defined type).
  • 4. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 4 Introduction  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.
  • 5. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 5 Introduction  After overloading the appropriate operators, you can use objects in expressions in just the same way you use C++'s built-in data types.
  • 6. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 6 Introduction  Consider following piece of code. Considering the + operator is overloaded in such a way with class String that it will concatenate two string objects. int main() { int n1 = 10, n2 = 20, n2; String s1 = “Rising”, s2=“Tech”, s3; n3 = n1 + n2; // addition s3 = s1 + s2; // concatenation }
  • 7. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 7 Overloading Operators  Operators come in three flavours:  Unary (++, --)  Binary (+, -)  Ternary (?:)  You are free to overload most of the built-in operators, but you cannot create new operators of your own.  Therefore, although you can give your class an increment operator (++), you cannot create a squared operator.
  • 8. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 8 Overloading Operators  You can overload these operators to do anything you want, but it is a good programming practice for them to make sense.  That means you can have the ++ operator to decrement, but it would make no sense to do so.
  • 9. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 9 Operators Function  Operators are overloaded by creating operator functions  An operator function defines the operations that the overloaded operator will perform relative to the class upon which it will work.  An operator function is created using the keyword operator  Operator functions can be either  Member function of a class or  Non-member function (Mostly Friend Functions)  The way operator functions are written differs between member and non-member functions.
  • 10. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 10 Member Operators Function  A member operator function for binary operators RetType ClassName::operator#(arg-list) { // operations }  Often, operator functions returns an object of the class they operate on, but ret-type can be any valid type.  The # is a placeholder. When you create an operator function, substitute the operator for the #.
  • 11. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 11 Member Operators Function RetType ClassName::operator#(arg-list) { // operations }  For example, if you are overloading the + operator, use operator+  While overloading binary operators using member function, the arg-list will contain one parameter.  A member operator function for binary operators
  • 12. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 12 Member Operators Function  A member operator function for Unary operators RetType ClassName::operator#() { // operations }  While overloading an unary operator, arg-list will be empty.
  • 13. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 13 Friend Operators Function  Instead of Member function, you can define operator functions that will be friend to the class you have created.
  • 14. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 14 Friend Operators Function  A friend operator function for binary operators RetType operator#(arg-list) { // operations }  While overloading a binary operator using friend function; argument list must take 2 arguments, one of them must be of user defined type.
  • 15. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 15 Friend Operators Function  A friend operator function for Unary operators RetType operator#(arg-list) { // operations }  While overloading an unary operator using friend function; argument list must have 1 argument as reference to the object.
  • 16. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 16 Overloading Operators : Rules  You can overload virtually any c++ operator, but you cannot create your own set of operators.  You cannot change any operators precedence.  You cannot change syntax to use an operator.  You cannot alter the pre-defined job performed by any operator, that means you cannot overload + operator in such a way to perform subtraction of two integers.
  • 17. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 17 Overloading Operators : Rules  You can overload most of Unary and Binary Operators, but you cannot overload the ternary operator (?:)  Binary as well as Unary operators can be overloaded by both Approaches  Member Functions Approach  Friend Function Approach
  • 18. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 18 Overloading Binary Operators  While overloading binary operators; at least one of its operand should be of user defined types.  The operator function must return an object.