17

Essential Operations

When someone says I want a programming language in which I need only say what I wish done, give him a lollipop.

– Alan Perlis

This chapter describes how vectors are copied and accessed through subscripting. To do that, we discuss copying in general and present the essential operations that must be considered for every type: construction, default construction, copy, move, and destruction. Like many types, vector offers comparisons, so we show how to provide operations such as == and <. Finally, we grapple with the problems of changing the size of a vector: why and how?

§17.1 Introduction

§17.2 Access to elements

§17.3 List initialization

§17.4 Copying and moving

Copy constructors; Copy assignments; Copy terminology;

Get Programming: Principles and Practice Using C++, 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.