The multiset::size() is a built-in function in C++ STL which returns the number of elements in the multiset container.
Syntax:
multiset_name.size()
Parameters: The function does not accept any parameters.
Return Value: The function returns the number of elements in the multiset container.
Below programs illustrate the above function:
Program 1:
// CPP program to demonstrate the // multiset::size() function #include <bits/stdc++.h> using namespace std; int main() { multiset<int> s; // Function to insert elements // in the multiset container s.insert(10); s.insert(13); cout << "The size of multiset: " << s.size(); s.insert(13); s.insert(25); cout << "\nThe size of multiset: " << s.size(); s.insert(24); cout << "\nThe size of multiset: " << s.size(); return 0; } |
The size of multiset: 2 The size of multiset: 4 The size of multiset: 5
Program 2:
// CPP program to demonstrate the // multiset::size() function #include <bits/stdc++.h> using namespace std; int main() { multiset<int> s; cout << "The size of multiset: " << s.size(); s.insert(2); s.insert(3); cout << "\nThe size of multiset: " << s.size(); s.insert(4); cout << "\nThe size of multiset: " << s.size(); return 0; } |
The size of multiset: 0 The size of multiset: 2 The size of multiset: 3
All functions of std::multiset
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- multiset lower_bound() in C++ STL with Examples
- multiset upper_bound() in C++ STL with Examples
- multiset max_size() in C++ STL with Examples
- Multiset in C++ Standard Template Library (STL)
- multiset::operator= in C++ STL
- multiset::swap() in C++ STL
- multiset::emplace() in C++ STL
- multiset insert() function in C++ STL
- multiset find() function in C++ STL
- multiset equal_range() function in C++ STL
- multiset clear() function in C++ STL
- multiset empty() function in C++ STL
- multiset count() function in C++ STL
- multiset emplace_hint() function in C++ STL
- multiset rbegin() and rend() function in C++ STL
- multiset crbegin() and crend() function in C++ STL
- multiset cbegin() and cend() function in C++ STL
- multiset begin() and end() function in C++ STL
- multiset get_allocator() function in C++ STL
- multiset max_size() in C++ STL
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

