title: Using vector to solve Sieve of Eratosthenes with C++ and recieving unusual error message
body: <p>Previously today, I asked a question about implementing a Sieve of Eratosthenes with 2D arrays and was told by a few people to use vectors instead. The only problem is I had no idea how to use Vectors in C++.</p>
  
  <p>I have rewritten my program today using a vector instead of a 2D array and it was going quite well until near the end of the program, where I receive the following error: </p>
  
  <blockquote>
    <p>sieve.h: In function ‘void printPrimes(std::vector*, int)’:
    sieve.h:42:20: error: no match for ‘operator&lt;&lt;’ in ‘std::cout &lt;&lt; *(primes + ((unsigned int)(((unsigned int)i) * 12u)))’</p>
  </blockquote>
  
  <p>I have never received this kind of error message before so I am unsure of how to fix this.</p>
  
  <p>Here is my revised code:</p>
  
  <blockquote>
    <p>sieve.h</p>
  </blockquote>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;cstdlib&gt;
  #include &lt;vector&gt;
  using namespace std;
  
  vector&lt;int&gt; calc_primes(int);
  void printPrimes(int[]);
  
  vector&lt;int&gt; calc_primes(int max)
  {
      vector&lt;int&gt; primes;
  
      for(int i = 2; i &lt; max; i++)
      {
          primes.push_back(i);
      }
  
      // for each value in the vector
      for(int i = 0; i &lt; primes.size(); i++)
      {
          //get the value
          int v = primes[i];
  
          if (v!=0) {
              //remove all multiples of the value
              int x = i+v;
              while(x &lt; primes.size()) {
                  primes[x]=0;
                  x = x+v;
              }
          }
      }
      return primes;
  }
  
  void printPrimes(vector&lt;int&gt;* primes, int size)
  {
  int primearray[size];
  for(int i = 0; i &lt; size; i++)
      {
          cout&lt;&lt;primes[i]&lt;&lt;endl;
      }
  }
  </code></pre>
  
  <blockquote>
    <p>sieve.cpp</p>
  </blockquote>
  
  <pre><code>#include "sieve.h"
  using namespace std;
  
  int main()
  {
      int max;
      cout&lt;&lt;"Please enter the max amount of prime numbers:"&lt;&lt;endl;
      cin&gt;&gt;max;
      vector&lt;int&gt; primes = calc_primes(max);
      printPrimes(primes, max);
      return 0;
  }
  </code></pre>