#include#include int main() { std::unordered_set hashSet = {1, 2, 3, 4}; for(auto it = hashSet.begin(); it != hashSet.end(); ++it) { std::cout << *it << " "; } // output: 1 2 3 4 return 0; }
#includeIn this example, we create a HashSet of integers and use the `erase()` method with the `begin()` iterator to remove the first element in the set, then we print the remaining elements to the console. The C++ HashSet is part of the C++ Standard Library.#include int main() { std::unordered_set hashSet = {1, 2, 3, 4}; hashSet.erase(hashSet.begin()); // erase the first element (1) for(auto it = hashSet.begin(); it != hashSet.end(); ++it) { std::cout << *it << " "; } // output: 2 3 4 return 0; }