How can I delete the last member from a set?
For example:
set<int> setInt;
setInt.insert(1);
setInt.insert(4);
setInt.insert(3);
setInt.insert(2);
How can I delete 4 from setInt? I tried something like:
setInt.erase(setInt.rbegin());
but I received an error.
By the way, if you’re doing this a lot (adding things to a set in arbitrary order and then removing the top element), you could also take a look at
std::priority_queue, see whether that suits your usage.