Part Five. Operators

One of the most powerful and important aspects of C++ is the ability to overload operators. It facilitates the extension of the language to user-defined types, enabling them to exhibit natural syntax and to be manipulable along with built-in types in generic code. Even before templates became a part of the language, the generalized approach afforded by operator overloading was invaluable. Now that we have templates, the possibilities are almost endless.

However, operator overloading has a dark side, which stems from several factors. Some programmers nonchalantly use overloads that contradict expected semantics.[1] Another problem is the fact that C++ is still living a dual life as a super-C, carrying with it all those implicit ...

Get Imperfect C++ Practical Solutions for Real-Life Programming now with O’Reilly online learning.

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