Syntax:
#include <list> iterator begin(); const_iterator begin() const;
The function begin() returns an iterator to the first element of the list. begin() should run in constant time.
For example, the following code uses begin() to initialize an iterator that is used to traverse a list:
// Create a list of characters list<char> my_list; for( int i = 0; i < 10; i++ ) { my_list.push_front( i + 'a' ); } // Display the list list<char>::iterator it; for( it = my_list.begin(); it != my_list.end(); ++it ) { cout << *it; }