© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
I. Horton, P. Van WeertBeginning C++23https://doi.org/10.1007/978-1-4842-9343-0_13

13. Operator Overloading

Ivor Horton1   and Peter Van Weert2
(1)
Stratford-upon-Avon, Warwickshire, UK
(2)
Kessel-Lo, Belgium
 

In this chapter, you’ll learn how to add support for operators such as + and < to your classes so that they can be applied to objects. This will make the types that you define behave more like fundamental data types and offer a more natural way to express some of the operations between objects. You’ve already seen how classes can have member functions that operate on the member variables of an object. Operator overloading enables you to write member functions ...

Get Beginning C++23: From Beginner to Pro 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.