Compartilhar via


list::cbegin

Returns a const iterator addressing the first element in a list.

const_iterator cbegin( ) const;

Return Value

A const bidirectional iterator addressing the first element in the list Class or to the location succeeding an empty list.

Remarks

With the return value of cbegin, the elements in the list object cannot be modified.

Example

// list_cbegin.cpp
// compile with: /EHsc
#include <list>
#include <iostream>

int main( ) 
{
   using namespace std;
   list <int> c1;
   list <int>::const_iterator c1_cIter;
   
   c1.push_back( 1 );
   c1.push_back( 2 );

   c1_cIter = c1.cbegin( );
   cout << "The first element of c1 is " << *c1_cIter << endl;
}

Output

The first element of c1 is 1

Requirements

Header: <list>

Namespace: std

See Also

Reference

list Class

Standard Template Library

Other Resources

list Class Members