Answers for "through map c++"

C++
1

through map c++

//Since c++17
for (auto& [key, value]: myMap) {
    cout << key << " has value " << value << endl;
}
//Since c++11
for (auto& kv : myMap) {
    cout << kv.first << " has value " << kv.second << endl;
}
Posted by: Guest on April-30-2021
0

iterate through map c++

for (auto i : m)
        cout << i.first << "   " << i.second
             << endl;
Posted by: Guest on July-22-2021

Browse Popular Code Answers by Language