共用方式為


deque::push_back

Adds an element to the end of the deque.

void push_back(
   const Type& _Val
);

Parameters

  • _Val
    The element added to the end of the deque.

Remarks

If an exception is thrown, the deque is left unaltered and the exception is rethrown.

Example

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

int main( ) 
{
   using namespace std;
   deque <int> c1;
   
   c1.push_back( 1 );
   if ( c1.size( ) != 0 )
      cout << "Last element: " << c1.back( ) << endl;

   c1.push_back( 2 );
   if ( c1.size( ) != 0 )
      cout << "New last element: " << c1.back( ) << endl;
}

Output

Last element: 1
New last element: 2

Requirements

Header: <deque>

Namespace: std

See Also

Concepts

deque Class

deque Class Members

deque::push_back and deque::pop_back

Standard Template Library