C++ vector begin() function
Example
Get the first element in a vector:
vector<string> cars = {"Volvo", "BMW", "Ford", "Mazda"};
vector<string>::iterator it = cars.begin();
cout << *it;
Try it Yourself »
Definition and Usage
The begin()
function returns an iterator pointing to the first element in a vector.
Syntax
vector.begin();
Parameter Values
None.
Technical Details
Returns: | An iterator pointing to the first element in the vector. |
---|
Related Pages
Read more about vectors in our Vector Tutorial.
Read more about iterators in our Iterators Tutorial.