Just use
auto
keyword to define your variable type. C++ compiler will infer the correct type for you.
void print_words(const std::map < std::string, int >& m1) {
std::cout << "Number of non-empty words: " << m1.size() << '\n';
int count = 0;
for (auto it = m1.begin(); it != m1.end(); ++it) {
}
}