19. Special Operators

We are all special cases.

– Albert Camus

Introduction

Special Operators

Subscripting; Function Call; Dereferencing; Increment and Decrement; Allocation and Deallocation; User-Defined Literals

A String Class

Essential Operations; Access to Characters; Representation; Member Functions; Helper Functions; Using Our String

Friends

Finding Friends; Friends and Members

Advice

19.1. Introduction

Overloading is not just for arithmetic and logical operations. In fact, operators are crucial in the design of containers (e.g., vector and map; §4.4), “smart pointers” (e.g., unique_ptr and shared_ptr; §5.2.1), iterators (§4.5), and other classes concerned with resource management.

19.2. Special Operators

The operators

[] ...

Get The C++ Programming Language, 4th 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.