返回集合中元素的数目。
size_type size( ) const;
返回值
当前设置的长度。
示例
// set_size.cpp
// compile with: /EHsc
#include <set>
#include <iostream>
int main( )
{
using namespace std;
set <int> s1;
set <int> :: size_type i;
s1.insert( 1 );
i = s1.size( );
cout << "The set length is " << i << "." << endl;
s1.insert( 2 );
i = s1.size( );
cout << "The set length is now " << i << "." << endl;
}
要求
标头: <set>
命名空间: std