Rewrite the code below using the ranged for loop and the auto keyword.
map<int,string> personIDs = {
{1,"Walt"},
{2,"Kenrick"}
};
map<int,string>::const_iterator iter;
for (iter = personIDs.begin();iter != personIDs.end();
iter++)
{
cout << iter->first << " " << iter->second << endl;
}
Correct Answer:
Verified
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q39: I have an algorithm that runs in
Q43: Suppose you want to run code that
Q43: The following code snippet is supposed
Q45: What is the difference between the iterators
Q48: Can you use the random_shuffle generic algorithm
Q49: Suppose we are given an STL vector
Q52: Why are the elements in the STL
Q54: Suppose you have a generic algorithm that
Q56: What is different about mathematical sets and
Q59: Suppose we are given an STL vector
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents