• Source
    1. #include<iostream>
    2. #include<set>
    3. #include<iterator>
    4. using namespace std;
    5.  
    6. int main()
    7. {
    8. set<int> t;
    9.  
    10. t.insert( 50 );
    11. t.insert( 60 );
    12. t.insert( 10 );
    13. t.insert( 20 );
    14. t.insert( 50 ); // this will not insert at set,
    15. // Because it is already in set
    16. t.insert( 30 );
    17.  
    18.  
    19. set<int>::iterator i; // You will see all data in Sort
    20. for( i = t.begin (); i!= t.end(); ++i)
    21. {
    22. cout << (*i) << " : " << endl;
    23. }
    24.  
    25. printf(" Size is %d\n",t.size() );
    26. t.clear(); // clear all
    27.  
    28. printf("\n\t\t*** Thanks ...\n");
    29. getchar();
    30. return 0;
    31. }