Assume proper includes have been executed, but not using directive or declaration. Write a definition of an iterator for a vector named vec of int values. Write a for loop that will display the contents vec on the screen, separated by spaces. Use iterators for the loop control.
What will be an ideal response?
```
#include
#include
using std::vector;
using std::cout;
using std::endl;
int main()
{
std::vector
std::vector
for(int i=0; i<10; i++)
vec.push_back(i);
for (itr = vec.begin(); itr != vec.end(); itr++)
cout << *itr << " ";
cout << endl;
return 0;
}
```
The parts that are requested in the problem are in bold face. The std:: on vector is necessary to make this code work with VC++6.0 prior to patch level 5. This hack does not affect the program under Borland command line compiler 5.5.
You might also like to view...
You can create a report with an embedded graph or image
Indicate whether the statement is true or false
Name at least three software programs where you can model and animate 3D objects.
What will be an ideal response?
What recovery tool is available from the Windows installation CD-ROM?
A. Automated System Recovery B. Last Known Good C. Recovery Console D. Safe Mode
The decimal value for each 8-bit portion of an IP address can range from ____________________ to ____________________.
Fill in the blank(s) with the appropriate word(s).