SlideShare a Scribd company logo
5
Most read
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

PPTX
Data members and member functions
PPT
08 c++ Operator Overloading.ppt
PPTX
Abstract class in c++
PPTX
Applets in java
PPTX
Inheritance in c++
PPTX
Inheritance in c++
PPTX
Method overloading
PPTX
Super keyword in java
Data members and member functions
08 c++ Operator Overloading.ppt
Abstract class in c++
Applets in java
Inheritance in c++
Inheritance in c++
Method overloading
Super keyword in java

What's hot (20)

PDF
Access specifiers (Public Private Protected) C++
PPTX
Operator overloading
PPTX
Inheritance in java
PPTX
Function overloading
PPTX
Object Oriented Programming Using C++
PPTX
Polymorphism in c++(ppt)
PPT
Polymorphism in java
PPT
Function overloading(c++)
PPTX
Friend functions
PPTX
classes and objects in C++
PPT
Static and Dynamic polymorphism in C++
PPTX
OPERATOR OVERLOADING IN C++
PPTX
Operator in c programming
PPT
Data independence
PPTX
class and objects
PPTX
Encapsulation C++
PDF
Operator overloading
PPTX
07. Virtual Functions
PPTX
Access specifiers(modifiers) in java
PPTX
Polymorphism in c++
Access specifiers (Public Private Protected) C++
Operator overloading
Inheritance in java
Function overloading
Object Oriented Programming Using C++
Polymorphism in c++(ppt)
Polymorphism in java
Function overloading(c++)
Friend functions
classes and objects in C++
Static and Dynamic polymorphism in C++
OPERATOR OVERLOADING IN C++
Operator in c programming
Data independence
class and objects
Encapsulation C++
Operator overloading
07. Virtual Functions
Access specifiers(modifiers) in java
Polymorphism in c++
Ad

Similar to Operator overloading and type conversions (20)

PDF
OOPS-Seminar.pdf
PDF
NIKUL SURANI
PPTX
Operator overloading
PPT
Lec 28 - operator overloading
PPTX
Operator overloading and type conversion in cpp
PPTX
Operator overloaing
PPT
Operator overloading
PPTX
Operator Overloading
PPT
9781285852744 ppt ch13
PPTX
Cpp (C++)
PPTX
Presentation on overloading
PPTX
OPERATING OVERLOADING IN VHDL
PPTX
C_plus_plus
PPT
Lec 26.27-operator overloading
PPT
Polymorphism
PPTX
Operator Overloading and Scope of Variable
PPTX
Operator overloading
PPTX
Operator overloading (binary)
PDF
Operator overloading
OOPS-Seminar.pdf
NIKUL SURANI
Operator overloading
Lec 28 - operator overloading
Operator overloading and type conversion in cpp
Operator overloaing
Operator overloading
Operator Overloading
9781285852744 ppt ch13
Cpp (C++)
Presentation on overloading
OPERATING OVERLOADING IN VHDL
C_plus_plus
Lec 26.27-operator overloading
Polymorphism
Operator Overloading and Scope of Variable
Operator overloading
Operator overloading (binary)
Operator overloading
Ad

Recently uploaded (20)

PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Essential Infomation Tech presentation.pptx
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Nekopoi APK 2025 free lastest update
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Operating system designcfffgfgggggggvggggggggg
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Reimagine Home Health with the Power of Agentic AI​
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Essential Infomation Tech presentation.pptx
Odoo Companies in India – Driving Business Transformation.pdf
Understanding Forklifts - TECH EHS Solution
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Design an Analysis of Algorithms I-SECS-1021-03
Nekopoi APK 2025 free lastest update
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
How to Migrate SBCGlobal Email to Yahoo Easily
Upgrade and Innovation Strategies for SAP ERP Customers
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Operating system designcfffgfgggggggvggggggggg

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