11. Overloading

The Devil is in the details.

traditional

Fine-grain overload resolution — ambiguity control — the null pointer — type-safe linkage — name mangling — controlling copying, allocation, derivation, etc. — smart pointers — smart references — increment and decrement — an exponentiation operator — user-defined operators — composite operators — enumerations — a Boolean type.

11.1 Introduction

Operators are used to provide notational convenience. Consider a simple formula F=M*A. No basic physics textbook states that as assign (F, multiply (M, A)). When variables can be of different types, we must decide whether to allow mixed-mode arithmetic or to require explicit conversion of operands to a common type. For example, if M is an int ...

Get The Design and Evolution of C++, First 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.