I am trying to write a program that takes in a upper bound(int) and then inserts all values up to that bound in a set and then use the sieve of Eratosthenes to remove all non prime integers. I am not sure what I am doing wrong.
Perhaps the dollar sign on line 13 might start explaining your problems. I think you are looking for the reference operator "&"
Also line 32, the "int <" operator is not defined for s.end() which is an iterator. Either use an iterator or use *s.rbegin(). I put the "*" sign to dereference the pointer so that you can access the value
Thank you so much I needed an extra set of eyes and that fixed 99% of my errors... now I am experiencing problems with my stdout statement. the compiler doesn't like the square brackets in s[i]
heres the error:
prog3.cc: In function ‘void print_primes(const std::set<int>&)’:
prog3.cc:18:44: error: no match for ‘operator[]’ in ‘s[i]’
Thanks the iterator fixed it... as for the looping structures, I started line 29 at 1 because I was inserting values from 1 to n, and n is a user defined upper bound. Thanks again you were a tremendous help