Compartir a través de


stack::push

Agrega un elemento al final superior de la pila.

void push( 
   const Type& _Val 
);

Parámetros

  • _Val
    El elemento agregado a la parte superior de la pila.

Comentarios

La parte superior de la pila es la posición que ocupa el elemento recientemente agregado y es el último elemento al final del contenedor.

Ejemplo

// stack_push.cpp
// compile with: /EHsc
#include <stack>
#include <iostream>

int main( )
{
   using namespace std;
   stack <int> s1;

   s1.push( 10 );
   s1.push( 20 );
   s1.push( 30 );

   stack <int>::size_type i;
   i = s1.size( );
   cout << "The stack length is " << i << "." << endl;

   i = s1.top( );
   cout << "The element at the top of the stack is "
        << i << "." << endl;
}
  

Requisitos

pila <deEncabezado: >

Espacio de nombres: std

Vea también

Referencia

stack (Clase)

Biblioteca de plantillas estándar