CIS 11: Data Structures and Algorithms
Project C
Complete Project 2e from Chapter 4 of the text. Directions are on page 209.
- Name your class keyed_bag2. You will submit its definition in keyed_bag2.h and the implementation in keyed_bag2.cpp.
- Set the data type of the bag as
typedef double value_type;
- Include member functions whose prototypes are:
keyed_bag2();
keyed_bag2(const keyed_bag2& source);
~keyed_bag2();
keyed_bag2& operator =(const keyed_bag2& source);
void insert(const value_type& entry, int key);
bool erase(int key);
value_type get(int key) const;
size_type size() const;
size_type count(const value_type& target) const;
bool has_key(int key) const;
- In order to provide standard behavior, be sure that the assignment operator returns *this.
- If an attempt is made to insert() an entry with a duplicate key, the existing entry should be replaced by one with the new value.
- Do not create a namespace for your class.
- For some design suggestions follow this link.
- Test your class thouroughly with your own interactive test program similar to the one presented on pp. 133-135 of the text. You will not submit the test program.
When you're satisfied with the definition and implementation, submit your work via the CATE form for Project C.
Legend: method/function keyword literal
2007/02/23