CIS-3050 Algorithms and Data Structures
This assignment is to refresh your C++
and make sure that you are comfortable with templates. It
consists of rewriting an existing Array implementation that is specific
for integer arrays into a template version of an array that can be used
to store a variety of types. To accomplish this, follow the steps
- Starting from the Array.cpp
code, rewrite the Array class into a
- Once you think you've made the necessary changes, test your
code by changing the driver.cpp
test file to
create Array<int>, rather than the existing Array.
- After you have your Array<int> working (and only then),
write a test driver that tests your implementation by using
- Lastly, write a user defined class, Person, which has a name
and an age. Write some tests that create an Array<Person>,
and verify that it works.
- You may use whatever development environment/C++ compiler you
- Include your name and what environment/compiler you used in
README file that you submit
- All the files you create/modify should be placed in a zip file
and submitted via Blackboard. The assignment is due by midnight
on Wednesday, Sept. 8.
- All code should have reasonable comments/style. I'm not
enforcing a set style, but your code should be readable, and include
comments about anything that is nonobvious. For this first
assignment, I will assume that you know what this means, and provide
guidance for violators. I do reserve the right to take
deductions if your code is particular hard to read/undocumented, but my
goal is just to coach you in the right direction, unless the violation
is particularly major.
I am assuming that you are all competent in C++, based on your previous
course work. You should all have access to previous C++ texts you
have used. Our text book also includes 2 chapters (1 and 2) on
C++ topics. You should use these resources (plus on line
resources) first. I will also be glad to answer questions
as needed -- ask early and often! However, if you find that this
assignment is totally beyond your scope of knowledge, please let me
know as soon as possible.
As needed, I can be reached via email, AIM or in my office on the 2nd
floor of the 700 building. See my schedule
for my official office hours. I also anticipate being
available during the afternoons until around 4p. I do not expect
to be at VTC on Monday, Sept. 6. If you do need help,
including your source code files in any email to me can be helpful and
- Getting the friend operator<< and operator>> methods
to compile is a bit tricky for a templated class. In order to
make them work, you have to have forward declarations:
template<class T> ostream& operator<< ( ostream&,
const Array<T> & );
template<class T> istream& operator>> ( istream&,
Array<T> & );
assuming that you used T for your
template variable. These three lines go before your declaration
of the Array class in your .h file
- You'll have to think about what member functions are necessary
for your Person class to work with your Array. It is only
necessary to include the functions necessary to get the class to work
in this environment.
- Do the steps in order. Get each piece working before
- You can either do a single test file, or create three test files,
one for each piece (intTest, stringTest, personTest)
- Don't forget to #include "Array.cpp" in your test file.
Good Luck and Good Coding!