Container Lab                
Description                
The files for this lab are in
~cs253/Lab/Container.
Copy them to your directory.
                
In this lab, we will examine a template class called
fix
, which implements a fixed-size array.
This is similar to std::
array
, as opposed to
std::
vector
, which implements a variable-size array.
                
Create a file called recit13.txt
, and turn it in for credit.
                
Exercises                
- With the instructor, read and understand fix.h
and main1.cc. Discuss the four methods
of traversing the container used in main1.cc.
- Compile and execute main1.cc.
Why is the fourth value so strange?
- Individually, examine main2.cc.
Even though
f[14]
doesn’t exist, no error message is given.
Change the operator[]
method in fix.h
to detect this error,
show a message, and exit.
- Individually, examine main3.cc.
Note that it uses fix3.h, not
fix.h. See the new
iterator
sub-class
of fix
, and the changes to begin()
and end()
?
In main3.cc, the last increment of the iterator is
invalid. However, this error is not detected. Change
fix3.h so that this error is detected, the same as
in the previous step.
How to submit your work:                
~cs253/bin/checkin RECIT13 recit13.txt
How to receive negative points:                
Turn in someone else’s work.