#include#include int main() { std::multiset mySet = {20, 30, 10, 20, 40}; // Creating a multiset with some values for (auto it = mySet.begin(); it != mySet.end(); ++it) { // Looping through the set std::cout << *it << " "; // Printing the elements } return 0; }
#includeThe above code examples use the standard library's C++ multiset template. The library for this is the Standard Template Library or STL.#include int main() { std::multiset mySet = {20, 30, 10, 20, 40}; // Creating a multiset with some values mySet.erase(mySet.end()); // Removing the last element for (auto it = mySet.begin(); it != mySet.end(); ++it) { // Looping through the set std::cout << *it << " "; // Printing the elements } return 0; }