Email: bknpk@hotmail.com Phone: +972-54-7649119


V

 

Simple c++ exercise which uses a hash. The key to hash is a name (string). The program is explained at: main page

  1. #include <iostream>
  2. #include <unordered_map>
  3. #include <string>
  4. //g++ -std=c++0x str_hash.cpp
  5. using namespace std;
  6. typedef string Name;
  7. int main(int argc, char* argv[])
  8. {
  9.   unordered_map<Name,int> my_hash;
  10.   my_hash["Pini Krengel"] = 63;
  11.   my_hash["Inbar"] = 12;
  12.   cout << "Inbar " << my_hash["Inbar"] << endl;
  13.   cout << "Pini " << my_hash["Pini Krengel"] << endl;
  14.   //cout << "Kuku " << my_hash["Kuku"] << endl;
  15.   return 0;
  16. }
  ...


Search This Site


Feedback This Site




new pages on this site