Suppose you want to run code that involves the loop
//Assume vector v and iterator p has been defined and
//given appropriate values
for (p = v.begin(); p != v.end(); p++)
cout << *p << " ";
Which of the following could you use to declare the iterator p? Why?
std::vector
std::vector
You could use either, but you probably should use const_iterator. In the loop, the iterator p is used to fetch from the container. There is no code that would change the container’s contents.
You might also like to view...
Tab settings can only be changed using the Tabs dialog box
Indicate whether the statement is true or false
Most operating systems create a significant number of temporary files in the course of operation. Which one of the following might leave behind "footprints" if the computer is not shut down gracefully?
a. Autosave files b. Print spooler files c. Undo files d. All of the above