Container Classes
Table of Contents

Introduction

A container class is a class designed to hold and organize multiple instances of another class.

Most well-defined containers will include functions that:

  • Create an empty container (via a constructor)
  • Insert a new object into the container
  • Remove an object from the container
  • Report the number of objects currently in the container
  • Empty the container of all objects
  • Provide access to the stored objects
  • Sort the elements (optional)

Two different varieties.

  • Value containers are compositions that store copies of the objects that they are holding (and thus are responsible for creating and destroying those copies).
  • Reference containers are aggregations that store pointers or references to other objects (and thus are not responsible for creation or destruction of those objects).
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.