Rewrite the code below using the ranged for loop and the auto keyword.
```
map
{1,"Walt"},
{2,"Kenrick"}
};
map
for (iter = personIDs.begin(); iter != personIDs.end();
iter++)
{
cout << iter->first << " " << iter->second << endl;
}
```
The auto keyword makes it easier to iterate over a collection.
```
for (auto p : personIDs)
{
cout << p.first << " " << p.second << endl;
}
```
You might also like to view...
If a set of functions have the same program logic and operations and differ only in the data type(s) each receives as argument(s) then a(n) __________ should be used.
a. Overloaded function. b. Recursive function. c. Macro. d. Function template.
Which of the following statements about computing in the 1940s and 1950s is false?
a) The earliest digital computers of the 1940s and 1950s included operating systems. b) Programmers often entered programs in machine language one bit at time using mechanical switches. c) Machine-language programs could be entered using punched cards. d) all of the above
When you double-click a template file in a folder, it opens a new ________
Fill in the blank(s) with correct word
Which of the following statements about array declaration is false?
A. The array size is optional. B. The array type must be specified. C. Arrays may be initialized when they are declared. D. Array declarations may be fixed or variable length. E. Once an array size is declared, it cannot be changed.