set compiler error

prog3.cc: In function ‘void print_primes(const std::set<int, std::less<int>, std::allocator<int> >&)’:
prog3.cc:11: error: expected primary-expression before ‘int’
prog3.cc:11: error: expected `;' before ‘int’
prog3.cc:15: error: ‘it’ was not declared in this scope


What am i missing

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <cstdlib>
#include <iostream>
#include <string>
#include <set>
#include <iomanip>

using namespace std;

void print_primes(const set<int>& s)
{
        int i = 0;

        s<int>::iterator it;

        for(it = s.begin(); it != s.end(); it++ )
                cout << *it << " ";
        if (++i >= 10)
        {
                int i = 0;
                cout << endl;
        }
}
int main()
{
        set<int> s;

        int upperLimit;
        int m = 2;
        cout << "Enter the value of the upper limit: ";
        cin >> upperLimit;

        print_primes(s);
}

Line 13 should be :
set<int>::iterator it;

Once that line was corrected - my compiler did not like this :
void print_primes(const set<int>& s)

change it to void print_primes(set<int>& s) //remove the const
If line 13 is
 
set<int>::const_iterator it;


then the function can take the set by const reference, which it should be.

That did it thanks!
Topic archived. No new replies allowed.