1 |
h08 |
CS24 F19 |
Name: | ||||
---|---|---|---|---|
(as it would appear on official course roster) | ||||
Umail address: | @umail.ucsb.edu | section |
||
Optional: name you wish to be called if different from name above. | ||||
Optional: name of "homework buddy" (leaving this blank signifies "I worked alone" |
h08: Chapter 6.1 - 6.6: Templates
ready? | assigned | due | points |
---|---|---|---|
true | Mon 11/18 12:00AM | Mon 11/25 11:59PM |
You may collaborate on this homework with AT MOST one person, an optional "homework buddy".
INSTEAD OF TURNING IN THIS HOMEWORK, YOU WILL TAKE A QUIZ ON GAUCHOSPACE BY THE DUE DATE.
There is NO MAKEUP for missed homework assignments.
The quiz will be made available at least two days before the due date.
Please:
- No Staples.
- No Paperclips.
- No folded down corners.
Complete your reading of Chapter 6, section 6.1 -6.2, 6.3 (ignore references to multiset of page 139), 6.4-6.6 (If you don’t have a copy of the textbook yet, there is one on reserve at the library under “COMP000-STAFF - Permanent Reserve”).
-
1. (10 pts) Write a template function named IsEqual() that compares two items and returns a boolean. If the items are equal the function should return true otherwise it should return false. The function has two parameters of the same type. Assume the template parameter is any type that has a copy constructor and the == operator defined.
2. (10 pts) Re-read pages 314-315. Then consider the Sequence class provided at the linkhttps://github.com/ucsb-cs24-w18/hw5/blob/master/sequence.h. The Sequence class currently stores a list of words in a static array. Convert this class to a template class that can be used to store a collection of any datatype instead of just std::string. Write the new definition of the Sequence class below. You don't have to implement the methods.