c++ map iterator on values code example
Example 1: c++ map iterator
#include <iostream>
#include <map>
int main() {
std::map<int, float> num_map;
// calls a_map.begin() and a_map.end()
for (auto it = num_map.begin(); it != num_map.end(); ++it) {
std::cout << it->first << ", " << it->second << '\n';
}
}
Example 2: cpp goiver all the map values
map<string, int>::iterator it;
for (it = symbolTable.begin(); it != symbolTable.end(); it++)
{
std::cout << it->first // string (key)
<< ':'
<< it->second // string's value
<< std::endl;
}