list::size
傳回list中項目的數目。
size_type size( ) const;
傳回值
傳回list目前的長度。
範例
// 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;
}
需求
標題: <list>
命名空間: std