Topical Information

This lab will help you practice dynamic memory mixed with classes.

Program Information

This program will involve implementing a dynamically allocated version of the mathematical concept of a 'set'. First, please examine the provided library and driver for a statically allocated Set class. (You may also want to refresh your mathematical memory of the set concept before proceeding.)

Now that you are familiar with how the Set class works, let's make it work better. Right now the user is limited to a certain maximum number of elements in their Set. You are to make it so that the number of elements can be set dynamically during the program's execution.

Extend the driver to test all the ADT's operations.

Thought Provoking Questions

  1. What (three) new methods will you need to add to handle the dynamic memory?

  2. Why do all the current methods pass Set objects as constant references?

  3. When is a copy constructor called?

  4. When is a destructor called?

  5. When is an assignment operator called?

  6. How do the assignment operator and copy constructor differ?

  7. How are the assignment operator and the destructor similar?

  8. What auxiliary method(s) might you employ to keep down the duplication of code in your class? (*cough* alloc *cough* destroy)

  9. Will you need to add any code to the existing methods? Why/why not?

This assignment is (Level 2.5).