10 Operator Overloading; Class string
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.
Use overloaded operators and additional features of class
string
.Create
PhoneNumber
,Date
andArray
classes that provide overloaded operators.Perform dynamic memory allocation with
new
anddelete
.Understand how keyword
explicit
prevents a constructor from being used for implicit conversions.Experience a “light-bulb moment” when you’ll truly appreciate the elegance and beauty of the class concept.
Get C++ How to Program, 10/e now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.