Reference:
Returns the number of elements in the set.
Function:
size_type size( ) const;
Return Value:
The current length of the set.
Example:
Output:
The set length is 1.
The set length is now 2.
Returns the number of elements in the set.
Function:
size_type size( ) const;
Return Value:
The current length of the set.
Example:
#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;
}
Output:
The set length is 1.
The set length is now 2.