#include <iostream>
#include <map>
#include <string>
int main() {
std::map<std::string, int> ages;
// Inserting key-value pairs
ages["Alice"] = 30;
ages["Bob"] = 25;
ages.insert({"Charlie", 35});
// Accessing and modifying values
ages["Bob"] = 26;
// Checking if a key exists
if (ages.count("David") == 0) {
std::cout << "David is not in the map" << std::endl;
}
// Iterating through the map
for (const auto& [name, age] : ages) {
std::cout << name << " is " << age << " years old." << std::endl;
}
// Erasing an element
ages.erase("Charlie");
return 0;
}