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 ...

Get Core C++ A Software Engineering Approach 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.