다음을 통해 공유


deque::back

Returns a reference to the last element of the deque.

reference back( ); 
const_reference back( ) const;

반환 값

The last element of the deque. If the deque is empty, the return value is undefined.

설명

If the return value of back is assigned to a const_reference, the deque object cannot be modified. If the return value of back is assigned to a reference, the deque object can be modified.

When compiling with _SECURE_SCL 1, a runtime error will occur if you attempt to access an element in an empty deque. 자세한 내용은 Checked Iterators를 참조하십시오.

예제

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

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

   int& i = c1.back( );
   const int& ii = c1.front( );

   cout << "The last integer of c1 is " << i << endl;
   i--;
   cout << "The next-to-last integer of c1 is " << ii << endl;
}
  

요구 사항

헤더: <deque>

네임스페이스: std

참고 항목

참조

deque 클래스

deque::front 및 deque::back

표준 템플릿 라이브러리