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:
How many constructors does the class have?
Does the class have a default constructor? What does this mean
for how the class will be used?
What are all the pre-processor directives
in Integerlist.h for?
What actions does the constructor take to ensure that
new IntegerList objects have a valid state?
What actions do setElement()
and getElement() take to ensure
that IntegerList objects continue to have a valid
state?
This class is supposed to improve on some aspects of the
behavior of arrays. How well does it do that?
What behaviors/features do arrays have
that IntegerList objects don't have?
- What would you have to do in order to create an "improved"
array-of-doubles class?
What command would you give to compile
the IntegerList class? What will the result be?
Do it. Did it work as you expected?
If you had a main() function in another
file, main.cpp, what single command would you give to
produce an executable?
Part II
- Write a simple main program that uses
the
IntegerList class. It should
- Ask the user how many
ints to read in;
- Create an
IntegerList object;
- Read in the numbers, sort them, and print them in ascending
(smallest-to-largest) order.
- Compile and run your program.