Set::begin() function is a bidirectional iterator used to return an iterator pointing to the first element of the set container.
Set::end() function is a bidirectional iterator used to return an iterator pointing to the last element of the set container.
Example Code
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
set<int> s;
set<int>::iterator it;
s.insert(7);
s.insert(6);
s.insert(1);
s.insert(4);
s.insert(2);
s.insert(9);
s.insert(10);
for (auto it=s.begin(); it != s.end(); ++it)
cout << ' ' << *it;
return 0;
}Output
1 2 4 6 7 9 10