Lab 5: Class Design

Part I

First, take a look at the IntegerList class at the end of Chapter 13. Write down your answers to the following questions, to turn in before you leave class today:
  1. How many constructors does the class have?
  2. Does the class have a default constructor? What does this mean for how the class will be used?
  3. What are all the pre-processor directives in Integerlist.h for?
  4. What actions does the constructor take to ensure that new IntegerList objects have a valid state?
  5. What actions do setElement() and getElement() take to ensure that IntegerList objects continue to have a valid state?
  6. This class is supposed to improve on some aspects of the behavior of arrays. How well does it do that?
  7. What behaviors/features do arrays have that IntegerList objects don't have?
  8. What would you have to do in order to create an "improved" array-of-doubles class?
  9. What command would you give to compile the IntegerList class? What will the result be?
  10. Do it. Did it work as you expected?
  11. If you had a main() function in another file, main.cpp, what single command would you give to produce an executable?

Part II

  1. Write a simple main program that uses the IntegerList class. It should
    1. Ask the user how many ints to read in;
    2. Create an IntegerList object;
    3. Read in the numbers, sort them, and print them in ascending (smallest-to-largest) order.
  2. Compile and run your program.