list::begin
Listedeki ilk öğe adresleme bir yineleyici döndürür.
const_iterator begin( ) const;
iterator begin( );
Dönüş Değeri
İlk öğe listesinde veya boş bir liste başarılı bir konuma adresleme çift yönlü Yineleyici.
Notlar
Dönüş değeri başlayan atanmış bir const_iterator, öğeler listesi nesnesi değiştirilemez.Dönüş değeri başlamak atanmış bir Yineleyici, öğeleri listesi nesnesi olarak değiştirilebilir.
Örnek
// list_begin.cpp
// compile with: /EHsc
#include <list>
#include <iostream>
int main( )
{
using namespace std;
list <int> c1;
list <int>::iterator c1_Iter;
list <int>::const_iterator c1_cIter;
c1.push_back( 1 );
c1.push_back( 2 );
c1_Iter = c1.begin( );
cout << "The first element of c1 is " << *c1_Iter << endl;
*c1_Iter = 20;
c1_Iter = c1.begin( );
cout << "The first element of c1 is now " << *c1_Iter << endl;
// The following line would be an error because iterator is const
// *c1_cIter = 200;
}
Gereksinimler
Başlık: <list>
Namespace: std