vector::const_reference

에 대 한 참조를 제공 하는 형식에 const 읽기 및 수행 하는 벡터에 저장 된 요소 const 작업.

typedef typename Allocator::const_reference const_reference;

설명

형식 const_reference 요소의 값을 수정 하는 데 사용할 수 없습니다.

예제

// vector_const_ref.cpp
// compile with: /EHsc
#include <vector>
#include <iostream>

int main( )
{
   using namespace std;
   vector <int> v1;
   
   v1.push_back( 10 );
   v1.push_back( 20 );

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

요구 사항

헤더: <vector>

네임 스페이스: std

참고 항목

참조

vector Class

표준 템플릿 라이브러리