#include <iostream>
#include <unordered_map>
#include <string>
int main() {
std::unordered_map<std::string, int> age_map;
// Inserting elements
age_map["Alice"] = 30;
age_map["Bob"] = 25;
age_map.insert({"Charlie", 35});
// Accessing elements
std::cout << "Alice's age: " << age_map["Alice"] << std::endl;
// Checking if a key exists
if (age_map.find("David") == age_map.end()) {
std::cout << "David not found in the map" << std::endl;
}
// Iterating through the map
for (const auto& pair : age_map) {
std::cout << pair.first << " is " << pair.second << " years old" << std::endl;
}
return 0;
}