This documentation is archived and is not being maintained.

deque::front

Returns a reference to the first element in a deque.

reference front( );
const_reference front( ) const;

Return Value

If the deque is empty, the return is undefined.

Remarks

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

Example

// deque_front.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.front( );
   const int& ii = c1.front( );

   cout << "The first integer of c1 is " << i << endl;
   i++;
   cout << "The second integer of c1 is " << ii << endl;
}

Output

The first integer of c1 is 10
The second integer of c1 is 11

See Also

deque Class | deque Members | deque::front and deque::back Sample

Show: