multiset::size() method in C++ STL

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

This article is written by

Please comment below, if you have any doubts or find any error in the above article.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top