Chapter 15

Overloading

We say a term is overloaded if it has many different meanings.1 A glance in any dictionary will show that many words in the English language are overloaded, and the meaning of a word in a particular situation is determined by context. In programming languages it is usually function or method names that are overloaded. As with words in English, a compiler will use contextual information to determine the exact meaning.

1. The term polymorphism is, for example, overloaded.

Overloading and overriding are both techniques that take a function or method named in a specific invocation and select for execution one out of potentially many different function bodies. But the two mechanisms differ in several regards. Most importantly, ...

Get An Introduction to Object-Oriented Programming, 3rd Edition 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.