#include <iostream>
#include <string>
#include <set>
#include <algorithm>
using namespace Std;
Int main () {
Set<int>a;
set<int>b;
set<int>x;
X.insert (1);
X.insert (2);
A.insert (5);
A.insert (6);
A.insert (7);
B.insert (4);
B.insert (6);
B.insert (8);
Set<int>::iterator IP;
for (Ip=a.begin (); Ip!=a.end (); ip++) {
cout << "A" is set to "<< *ip;
}cout << Endl;
for (Ip=b.begin (); Ip!=b.end (); ip++) {
cout << "B is set to" << *ip;
} cout << Endl;
//target collection x where to insert X.begin () from the head of x insert
Set_union (A.begin (), A.end (), B.begin (), B.end (), Inserter (X,x.begin ()));
For (Ip=x.begin (); Ip!=x.end (); ip++) {
cout << "assembly:" << *ip;
} cout << Endl;
X.clear ();
Set_intersection (A.begin (), A.end (), B.begin (), B.end (), Inserter (X,x.begin ()));
For (Ip=x.begin (); Ip!=x.end (); ip++) {
cout << "intersection:" << *ip;
}
cout << Endl;
X.clear ();
Set_difference (A.begin (), A.end (), B.begin (), B.end (), Inserter (X,x.begin ()));
For (Ip=x.begin (); Ip!=x.end (); ip++)
cout << "Difference set:" <<*ip;
cout <<endl; return 0;
}
C + + set_union set_intersection use