SlideShare a Scribd company logo
OPERATOR
OVERLOADING AND TYPE
CONVERSIONS
IN C++
KEY CONCEPTS
 OVERLOADING
 OPERATOR FUNCTIONS
 OVERLOADING UNARY OPERATORS
 STRING MANIPULATIONS
 BASIC TO CLASS TYPE
 CLASS TO CLASS TYPE
 OPERATOR OVERLOADING
 OVERLOADING BINARY OPERATORS
 USING FRIENDS FOR OVERLOADING
 TYPE CONVERSIONS
 CLASS TO BASIC TYPE
 OVERLOADING RULES
SUMMARY
 Operator overloading is one of the important features of C++ language that
enhances its exhaustibility.
 Using overloading feature we can add two user defined data types such as
objects , with the same syntax , just as basic data types.
 We can overload all the C++ operators except the following:
• Scope resolution operator(::)
• Class member access operator(.,.*)
• Size operator (sizeof)
• Conditional operator(?:)
 Operator overloading is done with the help of special function , called
operator function ,which describes the special task to an operator
SUMMARY CONTD
 There are certain restrictions and limitations in overloading operators.
Operator functions must either be member-functions(nonstatic) or friend
functions. The overloading operator must have at least one operand that is of
user-defined type.
 The compiler does not support automatic type conversions for the user-
defined data types. We can use casting operator to achieve this.
 The casting operator function should satisfy the following conditions:
• It must be a class member
• It must not specify a return type
• It must not have any arguments
KEY TERMS
 ARITHMETIC NOTATION
 BINARY OPERATORS
 CASTING
 CASTING OPERATOR
 CONSTRUCTOR
 CONVERSION FUNCTION
 DESTINATION CLASS
 FRIEND
 FRIEND FUNCTION
 FUNCTIONAL NOTATION
 MANIPULATING STRINGS
KEY TERMS CONTD
 OPERATOR
 OPERATOR FUNCTION
 OPERATOR OVERLOADING
 SCALAR MULTIPLICATION
 SEMANTICS
 SIZEOF
 SOURCE CLASS
 SYNTAX
 TEMPORARY OBJECT
 TYPE CONVERSIONS
 UNARY OPERATORS
REFERENCES
OBJECT ORIENTED PROGRAMMING WITH C++
-E. BALAGURUSAMY
Operator overloading and type conversions

More Related Content

What's hot (20)

PPTX
07. Virtual Functions
Haresh Jaiswal
 
PDF
Operator overloading C++
Lahiru Dilshan
 
PPTX
Static Data Members and Member Functions
MOHIT AGARWAL
 
PPTX
sSCOPE RESOLUTION OPERATOR.pptx
Nidhi Mehra
 
PDF
03 function overloading
Jasleen Kaur (Chandigarh University)
 
PPTX
[OOP - Lec 19] Static Member Functions
Muhammad Hammad Waseem
 
DOCX
Recursion in C++
Maliha Mehr
 
PPTX
Stream classes in C++
Shyam Gupta
 
PPT
Functions in c++
Maaz Hasan
 
PPTX
Abstract Base Class and Polymorphism in C++
Liju Thomas
 
PPT
Operator overloading
abhay singh
 
PPTX
Virtual function in C++ Pure Virtual Function
Kamlesh Makvana
 
PPTX
classes and objects in C++
HalaiHansaika
 
PPS
Wrapper class
kamal kotecha
 
PPTX
Pure virtual function and abstract class
Amit Trivedi
 
PPTX
Polymorphism In c++
Vishesh Jha
 
PPT
08 c++ Operator Overloading.ppt
Tareq Hasan
 
PPTX
Constructor and destructor
Shubham Vishwambhar
 
PPT
Operator overloading in C++
BalajiGovindan5
 
PPTX
class and objects
Payel Guria
 
07. Virtual Functions
Haresh Jaiswal
 
Operator overloading C++
Lahiru Dilshan
 
Static Data Members and Member Functions
MOHIT AGARWAL
 
sSCOPE RESOLUTION OPERATOR.pptx
Nidhi Mehra
 
03 function overloading
Jasleen Kaur (Chandigarh University)
 
[OOP - Lec 19] Static Member Functions
Muhammad Hammad Waseem
 
Recursion in C++
Maliha Mehr
 
Stream classes in C++
Shyam Gupta
 
Functions in c++
Maaz Hasan
 
Abstract Base Class and Polymorphism in C++
Liju Thomas
 
Operator overloading
abhay singh
 
Virtual function in C++ Pure Virtual Function
Kamlesh Makvana
 
classes and objects in C++
HalaiHansaika
 
Wrapper class
kamal kotecha
 
Pure virtual function and abstract class
Amit Trivedi
 
Polymorphism In c++
Vishesh Jha
 
08 c++ Operator Overloading.ppt
Tareq Hasan
 
Constructor and destructor
Shubham Vishwambhar
 
Operator overloading in C++
BalajiGovindan5
 
class and objects
Payel Guria
 

Similar to Operator overloading and type conversions (20)

PDF
Operator_Overloaing_Type_Conversion_OOPC(C++)
Yaksh Jethva
 
PDF
NIKUL SURANI
Nikul4470
 
PDF
Operator overloading
Pranali Chaudhari
 
PPTX
Operator overloading
ramya marichamy
 
PPTX
Operator overloaing
zindadili
 
PPTX
B.sc CSIT 2nd semester C++ Unit4
Tekendra Nath Yogi
 
PPTX
Operator overloading
Kumar
 
PPT
Operator overloading
ArunaDevi63
 
PPTX
Operator overloading2
zindadili
 
PDF
Ch-4-Operator Overloading.pdf
esuEthopi
 
PPTX
Operator Overloading
murugeswariSenthilku
 
PPTX
Operator overloadng
preethalal
 
PDF
Object Oriented Programming using C++ - Part 3
University College of Engineering Kakinada, JNTUK - Kakinada, India
 
PPTX
Cpp (C++)
Jay Patel
 
PPTX
oprators in cpp,types with example and details.pptx
komalrokade4
 
PPT
Lec 26.27-operator overloading
Princess Sam
 
PPTX
Oops
ankush_kumar
 
PPT
Lec 28 - operator overloading
Princess Sam
 
PPTX
Bca 2nd sem u-4 operator overloading
Rai University
 
Operator_Overloaing_Type_Conversion_OOPC(C++)
Yaksh Jethva
 
NIKUL SURANI
Nikul4470
 
Operator overloading
Pranali Chaudhari
 
Operator overloading
ramya marichamy
 
Operator overloaing
zindadili
 
B.sc CSIT 2nd semester C++ Unit4
Tekendra Nath Yogi
 
Operator overloading
Kumar
 
Operator overloading
ArunaDevi63
 
Operator overloading2
zindadili
 
Ch-4-Operator Overloading.pdf
esuEthopi
 
Operator Overloading
murugeswariSenthilku
 
Operator overloadng
preethalal
 
Object Oriented Programming using C++ - Part 3
University College of Engineering Kakinada, JNTUK - Kakinada, India
 
Cpp (C++)
Jay Patel
 
oprators in cpp,types with example and details.pptx
komalrokade4
 
Lec 26.27-operator overloading
Princess Sam
 
Lec 28 - operator overloading
Princess Sam
 
Bca 2nd sem u-4 operator overloading
Rai University
 
Ad

Recently uploaded (20)

PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Ad

Operator overloading and type conversions

  • 2. KEY CONCEPTS  OVERLOADING  OPERATOR FUNCTIONS  OVERLOADING UNARY OPERATORS  STRING MANIPULATIONS  BASIC TO CLASS TYPE  CLASS TO CLASS TYPE  OPERATOR OVERLOADING  OVERLOADING BINARY OPERATORS  USING FRIENDS FOR OVERLOADING  TYPE CONVERSIONS  CLASS TO BASIC TYPE  OVERLOADING RULES
  • 3. SUMMARY  Operator overloading is one of the important features of C++ language that enhances its exhaustibility.  Using overloading feature we can add two user defined data types such as objects , with the same syntax , just as basic data types.  We can overload all the C++ operators except the following: • Scope resolution operator(::) • Class member access operator(.,.*) • Size operator (sizeof) • Conditional operator(?:)  Operator overloading is done with the help of special function , called operator function ,which describes the special task to an operator
  • 4. SUMMARY CONTD  There are certain restrictions and limitations in overloading operators. Operator functions must either be member-functions(nonstatic) or friend functions. The overloading operator must have at least one operand that is of user-defined type.  The compiler does not support automatic type conversions for the user- defined data types. We can use casting operator to achieve this.  The casting operator function should satisfy the following conditions: • It must be a class member • It must not specify a return type • It must not have any arguments
  • 5. KEY TERMS  ARITHMETIC NOTATION  BINARY OPERATORS  CASTING  CASTING OPERATOR  CONSTRUCTOR  CONVERSION FUNCTION  DESTINATION CLASS  FRIEND  FRIEND FUNCTION  FUNCTIONAL NOTATION  MANIPULATING STRINGS
  • 6. KEY TERMS CONTD  OPERATOR  OPERATOR FUNCTION  OPERATOR OVERLOADING  SCALAR MULTIPLICATION  SEMANTICS  SIZEOF  SOURCE CLASS  SYNTAX  TEMPORARY OBJECT  TYPE CONVERSIONS  UNARY OPERATORS
  • 7. REFERENCES OBJECT ORIENTED PROGRAMMING WITH C++ -E. BALAGURUSAMY