다음을 통해 공유


deque::begin

Returns an iterator addressing the first element in the deque.

const_iterator begin( ) const; 
iterator begin( );

반환 값

A random-access iterator addressing the first element in the deque or to the location succeeding an empty deque.

설명

If the return value of begin is assigned to a const_iterator, the deque object cannot be modified. If the return value of begin is assigned to an iterator, the deque object can be modified.

예제

// 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 클래스

deque::begin 및 deque::end

표준 템플릿 라이브러리