Поделиться через


deque::begin

Возвращает итератор адресацию первый элемент в deque.

const_iterator begin( ) const; 
iterator begin( );

Возвращаемое значение

Итератор с произвольным доступом адресацию первый элемент в deque или в расположение преуспевая пустое deque.

Заметки

Если возвращаемое значение begin присвоено const_iterator, то объект deque нельзя изменить.Если возвращаемое значение begin присвоено iterator, то объект deque можно изменять.

Пример

// deque_begin.cpp
// compile with: /EHsc
#include <deque>
#include <iostream>

int main( ) 
{
   using namespace std;
   deque <int> c1;
   deque <int>::iterator c1_Iter;
   deque <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;
}
  

Требования

заголовок: <deque>

std пространство имен:

См. также

Ссылки

deque Class

deque::begin и deque::end

Стандартная библиотека шаблонов