pass map as reference c++

#include <iostream>
#include <map>

void modifyMap(std::map<int, std::string> &myMap) {
    // Step 1: Output the original map
    std::cout << "Original Map: ";
    for (const auto &pair : myMap) {
        std::cout << "{" << pair.first << ": " << pair.second << "} ";
    }
    std::cout << std::endl;

    // Step 2: Modify the values of the map
    for (auto &pair : myMap) {
        pair.second = "Modified";
    }

    // Step 3: Output the modified map
    std::cout << "Modified Map: ";
    for (const auto &pair : myMap) {
        std::cout << "{" << pair.first << ": " << pair.second << "} ";
    }
    std::cout << std::endl;
}

int main() {
    // Step 4: Create a map and populate it with initial values
    std::map<int, std::string> myMap = {{1, "One"}, {2, "Two"}, {3, "Three"}};

    // Step 5: Call the function to modify the map
    modifyMap(myMap);

    // Step 6: Output the final map from the main function
    std::cout << "Final Map in Main: ";
    for (const auto &pair : myMap) {
        std::cout << "{" << pair.first << ": " << pair.second << "} ";
    }
    std::cout << std::endl;

    return 0;
}