Objectives
In this chapter you’ll:
• Learn how operator overloading can help you craft valuable classes.
• Overload unary and binary operators.
• Convert objects from one class to another class.
• Use overloaded operators and additional features of the string
class.
• Create PhoneNumber
, Date
and Array
classes that provide overloaded operators.
• Perform dynamic memory allocation with new
and delete
.
• Use keyword explicit
to indicate that a constructor cannot be used for implicit conversions.
• Experience a “light-bulb moment” when you’ll truly appreciate the elegance and beauty of the class concept.
10.2 Using the Overloaded Operators of Standard Library Class string
10.3 Fundamentals of Operator Overloading
10.4 Overloading Binary Operators
10.5 Overloading the Binary Stream Insertion and Stream Extraction Operators
10.6 Overloading Unary Operators
10.7 Overloading the Unary Prefix and Postfix ++
and --
Operators
10.9 Dynamic Memory Management
10.10.2 Array
Class Definition
10.11 Operators as Member vs. Non-Member Functions
10.12 Converting Between Types
10.13 explicit
Constructors and Conversion Operators
10.14 Overloading the Function Call Operator ()