GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Tuesday, March 8, 2011

CPP - Set Assoc Containers

/**
 * This container just allow a one value. There's no duplicate of
 * the value. While multiset allows the duplication.
 */

#include <iostream>
#include <cstdlib>
#include <set>

using namespace std;

int main()
{
    system("color 2f");

    set<char*> data;
    set<char*>::iterator it;

    // inserting some data
    data.insert("Luna Maya");
    data.insert("Lady Gaga");
    data.insert("Bill Clinton");

    // removing some data
    data.erase("Lady Gaga");

    // iterating all over the data
    for(it = data.begin(); it!= data.end(); it++){
        cout << *it << endl;
    }

    return 0;
}

Share/Bookmark

No comments:

Post a Comment