Chapter 12. Classes and Dynamic Memory Allocation

In this chapter you’ll learn about the following:

• Using dynamic memory allocation for class members

• Implicit and explicit copy constructors

• Implicit and explicit overloaded assignment operators

• What you must do if you use new in a constructor

• Using static class members

• Using placement new with objects

• Using pointers to objects

• Implementing a queue abstract data type (ADT)

This chapter looks at how to use new and delete with classes and how to deal with some of the subtle problems that using dynamic memory can cause. This may sound like a short list of topics, but these topics affect constructor design, destructor design, and operator overloading.

Let’s look at a specific example ...

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

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