Udostępnij za pośrednictwem


stack::size

Zwraca liczbę elementów w stosie.

size_type size( ) const;

Wartość zwracana

Bieżąca długość stosu.

Przykład

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

Wymagania

Nagłówek: <stack>

Obszar nazw: std

Zobacz też

Informacje

stack Class

stack::size (STL Samples)

Standardowa biblioteka szablonu