Question
c++ visual studio 2019 Do not use #include Write a class template for a map with a fixed type for the keys string. and a
c++ visual studio 2019
Do not use #include
Write a class template for a map with a fixed type for the keys string. and a template type parameter for the values. Use open hashing (chaining) with an array or vector of pointers to STL linked lists. Provide the following public member functions:
- Constructor
- Destructor
- Copy constructor
- Assignment operator
- Operator ==
- Function size that returns the number of key-value pairs in the map
- Function count that returns the number of elements with a specific key
- Function insert that inserts a key-value pair into the map
- Function at that returns a reference to the mapped value of the element identified with a specific key k. If k does not match the key of any element in the map, the function should throw an out_of_range exception.
- Function erase that removes a key-value pair identified with a specific key k. If k does not match the key of any element in the map, the function should throw an out_of_range exception.
- Function key_comp that returns a key comparison object, a function object comparing keys and returning true if the first argument (key) for comparison is less than the second and false otherwise
Provide a test program to test your template with at least two different types of values.
Hint: First implement a class for values of some fixed data type, for example integer or string, and then convert it to a class template. It makes sense to submit both the non-template and the template versions.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started