Simple c++ exercise which uses a hash. The key to hash is a name (string).
The program is explained at:
main page
- #include <iostream>
- #include <unordered_map>
- #include <string>
- //g++ -std=c++0x str_hash.cpp
- using namespace std;
- typedef string Name;
- int main(int argc, char* argv[])
- {
- unordered_map<Name,int> my_hash;
- my_hash["Pini Krengel"] = 63;
- my_hash["Inbar"] = 12;
- cout << "Inbar " << my_hash["Inbar"] << endl;
- cout << "Pini " << my_hash["Pini Krengel"] << endl;
- //cout << "Kuku " << my_hash["Kuku"] << endl;
- return 0;
- }
|