list::size

Gibt die Anzahl der Elemente in einer Liste zurück.

size_type size( ) const;

Rückgabewert

Die aktuelle Länge der Liste.

Beispiel

// list_size.cpp
// compile with: /EHsc
#include <list>
#include <iostream>

int main( )
{
   using namespace std;
   list <int> c1;
   list <int>::size_type i;
   
   c1.push_back( 5 );
   i = c1.size( );
   cout << "List length is " << i << "." << endl;

   c1.push_back( 7 );
   i = c1.size( );
   cout << "List length is now " << i << "." << endl;
}
  
  

Anforderungen

Header: <list>

Namespace: std

Siehe auch

Referenz

list Class

Standardvorlagenbibliothek