Summary
In this chapter, we looked at the bells and whistles of C++: overloaded operator functions. Unlike the C++ features that were discussed in the previous chapters, overloaded operator functions are not absolutely necessary for writing high-quality C++ code.
One can even argue that, with the exception of a few classes such as Rational, Complex, and the like, the use of overloaded operators results in more confusion rather than making code easier to understand. The reason for this is that most classes are not like numeric types, and applying numeric operators is not straightforward.
For example, what do operator functions operator+() and operator<() mean for class Employee? Or for the class Transaction? Of course you can attach some meaning ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access