Overloaded Functions and Operators

Apart from classes and inheritance, C++ has one other major extension compared to ANSI C. This is the ability to overload function names and operators with additional meanings. This was taken from the language Algol68. It is useful in two ways.

Firstly, a number of different implementations of a function can be supplied, which have the same name but are differentiated by the number and types of their arguments. This is a similar effect to the way that some functional programming languages pattern match on their arguments.

Secondly, it is convenient to define meanings for standard operators, such as addition, when they are applied to user defined types.


Next note in series

Back to index