A simple, dynamic, bounds-checking array class will be designed in this lab. You will have an opportunity to use parameterized types, i.e., template classes and overloaded operators, explicitly manage memory, and incorporate checking for error conditions.
Array.h) that is part of the distribution for this lab. Do not vary from this specification.
Given a specification for an Array template class, write the methods
and operators for that class. The class represents an ADT with
operations such as
size. The array will be different from C++ builtin
arrays in two ways:
deletewill be used.
Your implementation needs to check for these conditions, and take appropriate action.
~cs342/bin/lab2. That will copy several files to a new
lab2subdirectory. You can
cd lab2and enter
maketo compile the code, if you like. However, it will not link until your implementation is filled in.
NOTE: you can use the distribution
mechanism to revert one or more of your files at any time. First,
delete the file (or better,
mv it to a file with a
different name, such as
Array.cc.BAD). Then, run
cvs update to update your workspace. That will replace
any missing files. It will also let you know of any files that you
modified but did not delete.
cvs is in pkg
gnu, in case you don't find it at first.
An Array.cc file is included which shows an implementation of the copy constructor. Use this as a model for implementing the rest of the assignment.
readme) documenting what you did to satisfy this assignment. Specifically mention what the most troublesome parts were. These files will be submitted automatically when you execute the command:
NOTE: there is a Makefile target that allows you to test what you are going to turn in:
It places the output that will be
turned in into the
TEST_TURNIN directory. Please use
make test_turnin, and verify that the files that you will
submit are correct.
g++, require that the implementation code for templates be available in the code that uses the parameterized type. That's why the
pkgadd g++), or egcs' g++ (
pkgadd egcs), you shouldn't have to worry about this.
template class Array<char>;
If you run
nm -C on your executable, you'll see
the template instantiations.
|Compiler||Automatic instantiation||Implicit instantiation||Explicit instantiation|
|Easy, but slow
and sometimes fragile
|Easiest, but largest code size
and non-unique static data members!
in template header file.
|Gives programmer control of instantiations.
in template header file.
|Sun CC 4.2||default||
|g++ 2.8.1 (