set: insert, end, begin : Set « Data Structure « C++






set: insert, end, begin

set: insert, end, begin

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

int main()
{
  set<string> setObject;

  setObject.insert("A");
  setObject.insert("B");
  setObject.insert("C");
  setObject.insert("D");

  set<string>::iterator p = setObject.begin();

  do {
    cout << *p << " ";
    p++;
  } while(p != setObject.end());
  cout << endl;

  p = setObject.find("C");
  if(p != setObject.end())
    cout << "Found a C\n";

  return 0;
}

           
       








Related examples in the same category

1.Using a multiset to record responses to a polling question.Using a multiset to record responses to a polling question.
2.Set operatrions: insert, size, begin, endSet operatrions: insert, size, begin, end