Write your question here.
I am trying to compile an example program from a book by Walter Savitch and get an error about the iterator and a namespace.
12 25 E:\Savichexamples\SourceCode\Chapter18\18-01.cpp [Error] 'std::vector<int>' is not a namespace
Put the code you need help with here.
//DISPLAY 18.1 Iterators Used with a Vector
//Program to demonstrate STL iterators.
#include <iostream>
usingnamespace std;
#include <vector>
using std::cout;
using std::endl;
using std::vector;
using std::vector<int>::iterator;
int main( )
{
usingnamespace std;
vector<int> container;
for (int i = 1; i <= 4; i++)
container.push_back(i);
cout << "Here is what is in the container:\n";
iterator p;
for (p = container.begin( ); p != container.end( ); p++)
cout << *p << " ";
cout << endl;
cout << "Setting entries to 0:\n";
for (p = container.begin( ); p != container.end( ); p++)
*p = 0;
cout << "Container now contains:\n";
for (p = container.begin( ); p != container.end( ); p++)
cout << *p << " ";
cout << endl;
return 0;
}