Hashable
Modify the HashMap class so that it uses polymorphism to allow redefinition of the the keys’ hash function. To do this, do the following:
Add an abstract class Hashable with a single pure virtual function
int hash()
. Classes that are derived from Hashable will implement hash to convert key values to an int in the range 0-9.Modify the HashMap to have keys that are pointers to Hashable objects.
Modify the HashMap’s
insert
andat
functions to use thehash
function when computing indices.Test the changes by creating a class that is derived from Hashable and implements the
hash
function. Use this class to test inserting items into the map.