title: How do you design a C++ class without making a std::vector a public member?
body: <p>I've seen this question: <a href="https://stackoverflow.com/questions/197211/class-design-with-vector-as-a-private-public-member">Class design with vector as a private/public member?</a>, but I don't feel that it answers the question.</p>
  
  <p>I have a class called <code>PrimeSieve</code> that can be initialized as <code>PrimeSieve s(10000)</code> to perform actions such as checking whether a number under 10000 is prime or listing all the primes under 10000. In particular, I'm wondering how to perform the latter function.</p>
  
  <p>Currently, I'm doing this, which I think violates the principles of OOP:</p>
  
  <pre><code>class PrimeSieve {
  public:
  ...
       std::vector&lt;long long&gt; primes;
  </code></pre>
  
  <p>The client will never need to change the vector, but how can I still allow the client to iterate through a vector of all of the primes under some number (using things like <code>vector.size()</code>? I've thought about an accessor method that returns the vector by value, but that seems inefficient.</p>