stack::size
Retorna o número de elementos na pilha.
size_type size( ) const;
Valor de retorno
O comprimento atual de pilha.
Exemplo
// stack_size.cpp
// compile with: /EHsc
#include <stack>
#include <iostream>
int main( )
{
using namespace std;
stack <int> s1, s2;
stack <int>::size_type i;
s1.push( 1 );
i = s1.size( );
cout << "The stack length is " << i << "." << endl;
s1.push( 2 );
i = s1.size( );
cout << "The stack length is now " << i << "." << endl;
}
Requisitos
Cabeçalho: <stack>
namespace: STD