共用方式為


deque::const_reference

提供對 const 項目的參考型別在讀取和執行 const 作業的雙向佇列儲存。

typedef typename Allocator::const_reference const_reference;

備註

const_reference 型別無法用來修改項目的值。

範例

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

int main( ) 
{
   using namespace std;
   deque <int> c1;
   
   c1.push_back( 10 );
   c1.push_back( 20 );

   const deque <int> c2 = c1;
   const int &i = c2.front( );
   const int &j = c2.back( );
   cout << "The first element is " << i << endl;
   cout << "The second element is " << j << endl;
   
   // The following line would cause an error as c2 is const
   // c2.push_back( 30 );
}
  

需求

標頭: <deque>

命名空間: std

請參閱

參考

deque 類別

標準樣板程式庫