Chapter 22. Operator Overloading


The whole difference between construction and creation is exactly this: that a thing constructed can only be loved after it is constructed; but a thing created is loved before it exists.

 --Gilbert Keith Chesterton

The die is cast.

 --Julius Caesar

Our doctor would never really operate unless it was necessary. He was just that way. If he didn’t need the money, he wouldn’t lay a hand on you.

 --Herb Shriner

In this chapter, you will learn:


What operator overloading is and how it makes programs more readable and programming more convenient.


To redefine (overload) operators to work with objects of user-defined classes.


The ...

Get C How to Program, Fifth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.