SlideShare a Scribd company logo
1 of 11
Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 1
Department of Information Technology
Operator Overloading
CE 142: Object Oriented
Programming with C++
Kamlesh Makvana
Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 2
Department of Information Technology
C++ Operator Overloading
 One to type of polymorphism
 Gives user defined meaning of operators
 i.e. perform operations on user defined data
types.
 Meaning of operator is already defined
by the compiler for built-in data types.
 Redefine same for user defined data
types like objects.
Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 3
Department of Information Technology
Why Operator Overloading
 Make program more readable
 c= add(c1,c2);
 c= c1+c2;
 z=add(mul(a,b),sub(x,y));
 z=(a*b)+(x-y);
Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 4
Department of Information Technology
How to overload Operator in C++
 Create a operator functions
 Operator functions could be a member
functions.
 Operator functions could be a normal user
defined functions.
Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 5
Department of Information Technology
Operator functions could be a
member functions
Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 6
Department of Information Technology
Operator functions could be a
member functions
Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 7
Department of Information Technology
Operator functions could be a
normal UDF.
Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 8
Department of Information TechnologyOperator functions could be
a normal UDF.
Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 9
Department of Information Technology
Rules for operator overloading
 Only existing operators is overloaded. Can
not create new operators.
 Overloaded operator must have at least one
operands.
 Basic meaning of operator could not be
changed.
 Some operators can not be overloaded like
dot(.), ::, ?:, sizeof, etc.
 We can not use friend function to overload
some operators like =, (), [], ->.
Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 10
Department of Information Technology
Rules for operator overloading
 If operator function is friend function
 Unary operator: one arguments.
 Binary operator: two arguments.
 If operator is non-static member function.
 Unary operator: no arguments.
 Binary operator: one arguments.
 Left-hand operand must be a type of relevant type.
 Binary arithmetic should explicitly return a value.
Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 11
Department of Information Technology
Overloading Binary Addition
operator

More Related Content

What's hot

Unary operator overloading
Unary operator overloadingUnary operator overloading
Unary operator overloadingBalajiGovindan5
 
Operator overloading and type conversion in cpp
Operator overloading and type conversion in cppOperator overloading and type conversion in cpp
Operator overloading and type conversion in cpprajshreemuthiah
 
08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.pptTareq Hasan
 
Binary operator overloading
Binary operator overloadingBinary operator overloading
Binary operator overloadingBalajiGovindan5
 
Operator overloading in C++
Operator  overloading in C++Operator  overloading in C++
Operator overloading in C++BalajiGovindan5
 
OPERATOR OVERLOADING IN C++
OPERATOR OVERLOADING IN C++OPERATOR OVERLOADING IN C++
OPERATOR OVERLOADING IN C++Aabha Tiwari
 
Operator overloading
Operator overloadingOperator overloading
Operator overloadingKumar
 
operator overloading
operator overloadingoperator overloading
operator overloadingNishant Joshi
 
Operator overloading and type conversions
Operator overloading and type conversionsOperator overloading and type conversions
Operator overloading and type conversionsAmogh Kalyanshetti
 
Presentation on overloading
Presentation on overloading Presentation on overloading
Presentation on overloading Charndeep Sekhon
 
Operator overloadng
Operator overloadngOperator overloadng
Operator overloadngpreethalal
 
#OOP_D_ITS - 4th - C++ Oop And Class Structure
#OOP_D_ITS - 4th - C++ Oop And Class Structure#OOP_D_ITS - 4th - C++ Oop And Class Structure
#OOP_D_ITS - 4th - C++ Oop And Class StructureHadziq Fabroyir
 
Lec 26.27-operator overloading
Lec 26.27-operator overloadingLec 26.27-operator overloading
Lec 26.27-operator overloadingPrincess Sam
 
Function overloading in c++
Function overloading in c++Function overloading in c++
Function overloading in c++BalajiGovindan5
 

What's hot (20)

Unary operator overloading
Unary operator overloadingUnary operator overloading
Unary operator overloading
 
Unary operator overloading
Unary operator overloadingUnary operator overloading
Unary operator overloading
 
operator overloading
operator overloadingoperator overloading
operator overloading
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Operator overloading and type conversion in cpp
Operator overloading and type conversion in cppOperator overloading and type conversion in cpp
Operator overloading and type conversion in cpp
 
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
 
Binary operator overloading
Binary operator overloadingBinary operator overloading
Binary operator overloading
 
Operator overloading in C++
Operator  overloading in C++Operator  overloading in C++
Operator overloading in C++
 
OPERATOR OVERLOADING IN C++
OPERATOR OVERLOADING IN C++OPERATOR OVERLOADING IN C++
OPERATOR OVERLOADING IN C++
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
operator overloading
operator overloadingoperator overloading
operator overloading
 
Operator overloading and type conversions
Operator overloading and type conversionsOperator overloading and type conversions
Operator overloading and type conversions
 
Presentation on overloading
Presentation on overloading Presentation on overloading
Presentation on overloading
 
Operator overloadng
Operator overloadngOperator overloadng
Operator overloadng
 
#OOP_D_ITS - 4th - C++ Oop And Class Structure
#OOP_D_ITS - 4th - C++ Oop And Class Structure#OOP_D_ITS - 4th - C++ Oop And Class Structure
#OOP_D_ITS - 4th - C++ Oop And Class Structure
 
Lec 26.27-operator overloading
Lec 26.27-operator overloadingLec 26.27-operator overloading
Lec 26.27-operator overloading
 
Overloading
OverloadingOverloading
Overloading
 
operator overloading in C++
operator overloading in C++operator overloading in C++
operator overloading in C++
 
Function overloading in c++
Function overloading in c++Function overloading in c++
Function overloading in c++
 

Similar to Operator overloading

OOPS-Seminar.pdf
OOPS-Seminar.pdfOOPS-Seminar.pdf
OOPS-Seminar.pdfRithiga6
 
Operator overloaing
Operator overloaingOperator overloaing
Operator overloaingzindadili
 
Object Oriented Technologies
Object Oriented TechnologiesObject Oriented Technologies
Object Oriented TechnologiesUmesh Nikam
 
Lec 28 - operator overloading
Lec 28 - operator overloadingLec 28 - operator overloading
Lec 28 - operator overloadingPrincess Sam
 
Glutter – A Visual Programming Environment for Complex Event Processing
Glutter – A Visual Programming Environment for Complex Event ProcessingGlutter – A Visual Programming Environment for Complex Event Processing
Glutter – A Visual Programming Environment for Complex Event Processingcscpconf
 
9781285852744 ppt ch13
9781285852744 ppt ch139781285852744 ppt ch13
9781285852744 ppt ch13Terry Yoast
 
Principles of object oriented programing
Principles of object oriented programingPrinciples of object oriented programing
Principles of object oriented programingAhammed Alamin
 
Oop05 6
Oop05 6Oop05 6
Oop05 6schwaa
 
NIKUL SURANI
NIKUL SURANINIKUL SURANI
NIKUL SURANINikul4470
 
Mca 2nd sem u-4 operator overloading
Mca 2nd  sem u-4 operator overloadingMca 2nd  sem u-4 operator overloading
Mca 2nd sem u-4 operator overloadingRai University
 
Best Practices & Lessons Learned from the field on EMC Documentum xCP 2.0
Best Practices & Lessons Learned from the field on EMC Documentum xCP 2.0Best Practices & Lessons Learned from the field on EMC Documentum xCP 2.0
Best Practices & Lessons Learned from the field on EMC Documentum xCP 2.0Haytham Ghandour
 
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 overloadingRai University
 

Similar to Operator overloading (20)

OOPS-Seminar.pdf
OOPS-Seminar.pdfOOPS-Seminar.pdf
OOPS-Seminar.pdf
 
Operator overloaing
Operator overloaingOperator overloaing
Operator overloaing
 
Cpp tokens (2)
Cpp tokens (2)Cpp tokens (2)
Cpp tokens (2)
 
Cpp (C++)
Cpp (C++)Cpp (C++)
Cpp (C++)
 
Object Oriented Technologies
Object Oriented TechnologiesObject Oriented Technologies
Object Oriented Technologies
 
Lec 28 - operator overloading
Lec 28 - operator overloadingLec 28 - operator overloading
Lec 28 - operator overloading
 
Glutter – A Visual Programming Environment for Complex Event Processing
Glutter – A Visual Programming Environment for Complex Event ProcessingGlutter – A Visual Programming Environment for Complex Event Processing
Glutter – A Visual Programming Environment for Complex Event Processing
 
Operator Overloading in C++
Operator Overloading in C++Operator Overloading in C++
Operator Overloading in C++
 
9781285852744 ppt ch13
9781285852744 ppt ch139781285852744 ppt ch13
9781285852744 ppt ch13
 
Principles of object oriented programing
Principles of object oriented programingPrinciples of object oriented programing
Principles of object oriented programing
 
Oop05 6
Oop05 6Oop05 6
Oop05 6
 
NIKUL SURANI
NIKUL SURANINIKUL SURANI
NIKUL SURANI
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Mca 2nd sem u-4 operator overloading
Mca 2nd  sem u-4 operator overloadingMca 2nd  sem u-4 operator overloading
Mca 2nd sem u-4 operator overloading
 
Best Practices & Lessons Learned from the field on EMC Documentum xCP 2.0
Best Practices & Lessons Learned from the field on EMC Documentum xCP 2.0Best Practices & Lessons Learned from the field on EMC Documentum xCP 2.0
Best Practices & Lessons Learned from the field on EMC Documentum xCP 2.0
 
Object Oriented Programming using C++ - Part 3
Object Oriented Programming using C++ - Part 3Object Oriented Programming using C++ - Part 3
Object Oriented Programming using C++ - Part 3
 
GCF
GCFGCF
GCF
 
Oops
OopsOops
Oops
 
COCOMO MODEL
COCOMO MODELCOCOMO MODEL
COCOMO MODEL
 
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
 

Recently uploaded

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Recently uploaded (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

Operator overloading

  • 1. Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 1 Department of Information Technology Operator Overloading CE 142: Object Oriented Programming with C++ Kamlesh Makvana
  • 2. Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 2 Department of Information Technology C++ Operator Overloading  One to type of polymorphism  Gives user defined meaning of operators  i.e. perform operations on user defined data types.  Meaning of operator is already defined by the compiler for built-in data types.  Redefine same for user defined data types like objects.
  • 3. Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 3 Department of Information Technology Why Operator Overloading  Make program more readable  c= add(c1,c2);  c= c1+c2;  z=add(mul(a,b),sub(x,y));  z=(a*b)+(x-y);
  • 4. Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 4 Department of Information Technology How to overload Operator in C++  Create a operator functions  Operator functions could be a member functions.  Operator functions could be a normal user defined functions.
  • 5. Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 5 Department of Information Technology Operator functions could be a member functions
  • 6. Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 6 Department of Information Technology Operator functions could be a member functions
  • 7. Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 7 Department of Information Technology Operator functions could be a normal UDF.
  • 8. Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 8 Department of Information TechnologyOperator functions could be a normal UDF.
  • 9. Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 9 Department of Information Technology Rules for operator overloading  Only existing operators is overloaded. Can not create new operators.  Overloaded operator must have at least one operands.  Basic meaning of operator could not be changed.  Some operators can not be overloaded like dot(.), ::, ?:, sizeof, etc.  We can not use friend function to overload some operators like =, (), [], ->.
  • 10. Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 10 Department of Information Technology Rules for operator overloading  If operator function is friend function  Unary operator: one arguments.  Binary operator: two arguments.  If operator is non-static member function.  Unary operator: no arguments.  Binary operator: one arguments.  Left-hand operand must be a type of relevant type.  Binary arithmetic should explicitly return a value.
  • 11. Classified e-Material ©Copyrights Charotar Institute of Technology, Changa 11 Department of Information Technology Overloading Binary Addition operator