I am trying to access the value of particular hash key. The example code is below. Test Here
// unordered_map::at
#include <iostream>
#include <string>
#include <unordered_map>
int main ()
{
std::unordered_map<std::string,int> hashmap = {
{ "Apple", 300},
{ "Banana", 60},
{ "Orange", 70 } };
std::cout << "Value :" << hashmap[300]<<std::endl;
return 0;
}
However when I try to access key of a particular value, it works fine, like hashmap["Apple"]
, it give 300
i,e the key of Apple
. How to make it work otherwise like hashmap[300]
to give "Apple" .