Declare a string set : set « set multiset « C++ Tutorial






#include <iostream>
#include <set>
#include <string>

using namespace std;

int main( ) {

   set<string> setStr;
   string s = "B";

   setStr.insert(s);
   s = "S";
   setStr.insert(s);
   s = "R";
   setStr.insert(s);
   s = "H";
   setStr.insert(s);

   for (set<string>::const_iterator p = setStr.begin( );p != setStr.end( ); ++p)
      cout << *p << endl;
}
B
H
R
S








19.1.set
19.1.1.Declare a string set
19.1.2.Use array to initialize a set
19.1.3.Read keyboard input to a set directly
19.1.4.Assigning sets to each other
19.1.5.Add elements in a list to a set