10.3 Fundamentals of Operator Overloading
As you saw in Fig. 10.1, overloaded operators provide a concise notation for manipulating string
objects. You can use operators with your own user-defined types as well. Although C++ does not allow new operators to be created, it does allow most existing operators to be overloaded so that, when they’re used with objects, they have meaning appropriate to those objects.
10.3.1 Operator Overloading Is Not Automatic
You must write operator-overloading functions to perform the desired operations. An operator is overloaded by writing a non-static
member function definition or non-member function definition as you normally would, except that the function name starts with the keyword operator
followed by the ...
Get C++ How to Program, 10/e 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.