Multisets are associative containers available in the C++ Standard Library. They are similar to sets with an addition that multiple keys with equivalent values are allowed. The multiset::size()
is a method available in the STL that returns the number of elements present in the multiset.
Syntax:
set_name.size();
Parameters: The multiset::size()
does not accept any parameter:
Return value: size of container
Example of multiset::size() method
#include <iostream> #include <set> using namespace std; int main() { multiset<int> m; m.insert(1); m.insert(2); m.insert(3); m.insert(4); cout<<"Size: "<<m.size()<<endl; }
Output:
Size: 4