=====begin=====
Syntax:
#include
iterator begin();
const_iterator begin() const;
The function begin() returns an iterator to the first element of the vector,
and runs in [[/complexity|constant time]].
For example, the following code uses begin() to initialize an iterator that is
used to traverse the elements of a vector:
vector words;
string str;
while( cin >> str ) words.push_back(str);
for( vector::const_iterator iter = words.begin();
iter != words.end(); ++iter ) {
cout << *iter << endl;
}
When given this input:
hey mickey you're so fine
...the above code produces the following output:
hey
mickey
you're
so
fine
Related Topics: [[vector_operators|[] operator]], [[at]], [[end]], [[rbegin]], [[rend]]