Answers for "c++ map find iterator"

C++
7

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';
  }
}
Posted by: Guest on March-08-2020
0

c++ iterate map

// C++11 and onwards
for (auto const& keyValue : map)
{
  keyValue.first; // Key
  keyValue.second; // Value
}
Posted by: Guest on December-03-2021

Browse Popular Code Answers by Language