Create sets with string elements : set « Set Multiset « C++





Create sets with string elements

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

using namespace std;

template <class T>
void print(T& c){
   for( typename T::iterator i = c.begin(); i != c.end(); i++ ){
      std::cout << *i << endl;
   }
}

int main()
{
  set<string> first;

  first.insert("r");
  first.insert("T");
  first.insert("s");

}
  
    
  










Related examples in the same category

1.Declare a string set
2.Use array to initialize a set
3.Read keyboard input to a set directly
4.Add elements in a list to a set
5.Create a set that contains list1 - list2
6.Assigning sets to each other