Contents

Section 13.1 Copy, Assign, and Destroy

Section 13.2 Copy Control and Resource Management

Section 13.3 Swap

Section 13.4 A Copy-Control Example

Section 13.5 Classes That Manage Dynamic Memory

Section 13.6 Moving Objects

Chapter Summary

Defined Terms

As we saw in Chapter 7, each class defines a new type and defines the operations that objects of that type can perform. In that chapter, we also learned that classes can define constructors, which control what happens when objects of the class type are created.

In this chapter we’ll learn how classes can control what happens when objects of the class type are copied, assigned, moved, or destroyed. Classes control these actions through special member functions: the copy constructor, move constructor, ...

Get C++ Primer, Fifth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.