Originally posted by kes103
I know that the statement is intended to instantiate location as an integer vector.
Actually, that is not true. The statement is intended to instantiate location as an iterator that can be used with a vector of integers.
The iterator class, like lyx said, is nested within the vector class. For all of the STL containers there is an iterator and a const_iterator. These objects are used to identify a single position within the container.
For example, if you wanted to go through each element in your vector (in other words, iterate over it), you would declare an iterator, then set it to the beginning of the vector and increment it one at a time until you reach the end. Here is an example that adds two to each entry in the vector:
Code:
std::vector<int> intVec; // Instantiate intVec as an integer vector
std::vector<int>::iterator location; // Create iterator for integer vector.
...
// Get an iterator that points to one past the last element.
std::vector<int>::iterator end = intVec.end();
// Make the iterator point to the first element.
location = intVec.begin();
// Keep incrementing until the current location reaches the end;
for (; location != end(); ++location)
{
(*location) += 2;
}
As far saying it, you rarely read it aloud. I guess you would just call location an iterator and it if necessary make the distinction that it is an iterator for a vector of ints.