Context
Creating a Hash Table in C++
This is what all major companies do (from what I know). Hash maps to store data. But C++, for some reason, does not have it readily available in store. So one has to create their own. Most basic <key,value> pair combination is <int, string> pair and hence I used the same. Depending on requirement this can change, even to <const void*, const void*> pair.
My Code
Implement a Hash class with simple put() and get() methods. Use a main() method to store and retrieve data from Hash object.
Caveat 1
By not including the & in the method signature for put() in Hash class we end up consuming more space! Notice the address values are different.
Caveat 2
Memory allocation for the Hash object 'my_object' and input strings should be from heap, as per C++ standards. But it can be observed that the address locations in the sample outputs are increasing from low to high in a regular fashion. Looks like the program objects are using the pre-allocated stack memory for the process.
Learning