次の方法で共有


deque::begin

deque の一つ目の要素を指定する反復子を返します。

const_iterator begin( ) const; 
iterator begin( );

戻り値

deque または空の deque を成功する場所への最初の要素を示すランダム アクセス反復子。

解説

開始 の戻り値が const_iteratorに割り当てると、deque オブジェクトは変更できません。 開始 の戻り値が 反復子に割り当てると、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 クラス

deque::begin と deque::end

標準テンプレート ライブラリ