*** 容器set的使用

#include <iostream>
#include <set>
using namespace std;

int main()
{
    set <string> st;
    
    st.insert("apple");
    st.insert("orange");
    st.insert("strawberry");
    st.insert("peach");
    st.insert("orange");
    st.insert("banana");
    
    for (set<string>::iterator i=st.begin(); i!=st.end(); i++)
    {
        cout << *i << endl;
    }
    
    cout << "==== after erase peach ====" << endl;
    st.erase("peach");
    
    for (set<string>::iterator i=st.begin(); i!=st.end(); i++)
    {
        cout << *i << endl;
    }
    
    return 0 ;
}
原文地址:https://www.cnblogs.com/superrunner/p/10211263.html