front
Syntax:
#include <vector> TYPE& front(); const TYPE& front() const; The front() function returns a reference to the first element of the vector, and runs in constant time. For example, the following code uses a vector and the sort() algorithm to display the first word (in alphabetical order) entered by a user: vector When provided with this input: now is the time for all good men to come to the aid of their country ...the above code displays: In alphabetical order, the first word is 'aid'. |