Operator Overloading: A Brief Overview

An overloaded operator is a programmer-defined function that has a special name (composed of the keyword operator and the operator symbol or symbols). Overloaded operators are also known by the names of operator functions, overloaded operator function, or just operators. They provide the convenience of operator syntax for manipulating objects of programmer-defined classes.

The driving force behind the incorporation of overloaded operators into C++ is the desire to treat objects of programmer-defined types in the same way as variables of built-in types are treated. If you can add two numeric values, there is no good reason why you cannot add two Account objects. If you can add three numeric values, you should ...

Get Core C++ A Software Engineering Approach now with O’Reilly online learning.

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