When you iterate over a map, each element is a pair where .first is the key and .second is the value. Example: map<string, int> ages; ages["Alice"] = 25; for (auto& p : ages) { cout << p.first << ": " << p.second; } This prints "Alice: 25".
You can also use structured bindings (C++17): for (auto& [name, age] : ages) { cout << name << ": " << age; } This is cleaner when you need both the key and value. Understanding that map elements are pairs helps you write cleaner iteration code and use algorithms like find_if that work on pairs.