begin
Syntax: #include <string> iterator begin(); const_iterator begin() const; The function begin() returns an iterator to the first element of the string. 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> charList; for( int i=0; i < 10; i++ ) { charList.push_front( i + 65 ); } // Display the list list<char>::iterator theIterator; for( theIterator = charList.begin(); theIterator != charList.end(); theIterator++ ) { cout << *theIterator; } Related topics:
|