stack::size

Restituisce il numero di elementi nello stack.

size_type size( ) const;

Valore restituito

La lunghezza dello stack corrente.

Esempio

// 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;
}
  
  

Requisiti

intestazione: <stack>

Spazio dei nomi: deviazione standard

Vedere anche

Riferimenti

stack Class

stack::size (STL Samples)

Libreria di modelli standard