Link to home
Start Free TrialLog in
Avatar of Troudeloup
Troudeloup

asked on

[noob][c++] set:: accessors & mutators

#include <iostream>
#include <set>

using namespace std;

int main()
{
      set<int, greater<int> > s;
      set<int, greater<int> >::iterator i;

      s.insert(4);
      s.insert(1);
      s.insert(2);
      s.insert(4);
      s.insert(3);
      s.insert(6);
         

       cout << "The set contains the elements: " << endl;
       for (i=s.begin();  i !=s.end();  i++)
       {
       cout << *i  << endl;
       }
}



http://www.cplusplus.com/reference/stl/set/



       cout << "The set contains the elements: " << endl;
       for (i=s.begin();  i !=s.end();  i++)
       {
       cout << *i  << endl;
       }



while I understand that this is a for loop, I don't get how the individual parts work.


1)  how do I cout an element of the set?

     i know it's not

     cout << s << endl;


2)  more to follow.
SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Troudeloup
Troudeloup

ASKER

also, I cannot

cout << *i << endl;

directly right?
SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial