Compartilhar via


stack::pop

Remove o elemento da parte superior da pilha.

void pop( );

Comentários

A pilha deve ser não vazio a aplicação da função de membro. A parte superior da pilha é a posição ocupada pelo elemento é adicionado recentemente e o elemento o último no final do contêiner.

Exemplo

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

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

   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;

   s1.pop( );

   i = s1.size( );
   cout << "After a pop, the stack length is " 
        << i << "." << endl;

   i = s1.top( );
   cout << "After a pop, the element at the top of the stack is "
        << i << "." << endl;
}
  

Requisitos

pilha <deCabeçalho: >

Namespace: std

Consulte também

Referência

Classe de pilha

Biblioteca de Modelos Padrão