how to remove the last element of the set in c++ code example Example: c++ erase last element of set st.erase(*st.rbegin()); // or st.erase(prev(st.end()));