Related Articles

Related Articles

multimap size() function in C++ STL
  • Last Updated : 29 Jun, 2018

The multimap::size() is a built-in function in C++ STL which returns the number of elements in the multimap container.

Syntax:

multimap_name.size()

Parameters: The function does not accept any parameter.

Return Value: This function returns the number of elements a multimap container has.

filter_none

edit
close

play_arrow

link
brightness_4
code

// C++ function for illustration
// multimap::size() function
#include <bits/stdc++.h>
using namespace std;
  
int main()
{
  
    // initialize container
    multimap<int, int> mp;
  
    // insert elements in random order
    mp.insert({ 2, 30 });
    mp.insert({ 1, 40 });
    mp.insert({ 2, 60 });
    mp.insert({ 2, 20 });
    mp.insert({ 1, 50 });
    mp.insert({ 4, 50 });
  
    cout << "multimap mp has " << mp.size()
         << " number of elements";
    return 0;
}

chevron_right


Output:

multimap mp has 6 number of elements

Attention reader! Don’t stop learning now. Get hold of all the important C++ Foundation and STL concepts with the C++ Foundation and STL courses at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :