Container Classes

Programming Assignment 1

Homework Assignment 1

Bags

Initial State of a Bag

Inserting Numbers into a Bag

Examining a Bag

Removing a Number from a Bag

How Many Numbers

Summary of the Bag Operations

The Bag Class

PPT Slide

The Bag’s Default Constructor

The Insert Function

The Size Function

The Occurrences Function

The Remove Function

Using the Bag in a Program

The Header File and Implementation File

Documentation for the Bag Class

The Bag’s Class Definition

The Implementation File

A Quiz

Implementation Details

An Exercise

The Invariant of the Bag ADT

Invariant of the Bag ADT (ctd.)

Invariant Documentation

Invariant documentation (ctd.)

An Example of Calling Insert

Pseudocode for Bag::insert

The Other Bag Operations

Other Kinds of Bags

Summary

THE END

Constructor for the Bag ADT

Value Semantics

Member Functions

Operator +=

Operator +

The List ADT

Email: mgv@cs.sc.edu

Home Page: www.cs.sc.edu/~mgv

Other information: These slides are modifications of slides provided by the authors of the textbook.