Chapter 5 Classes and Dynamic Memory Allocation

With the classes described in the previous chapter, each object remains the same size during its lifetime. It's also possible to write a class whose objects can change in size dynamically. This chapter describes some of the issues relating to dynamically resizeable classes.

This chapter covers the following topics:

The free store

The assignment operator

The this pointer

The copy constructor

Passing and returning objects

Passing and returning references

Before continuing the discussion of classes, let's consider how you perform dynamic memory allocation in C++.