title: How to return a 'read-only' copy of a vector
body: <p>I have a class which has a private attribute vector rectVec;</p>
  
  <pre><code>class A {
  private:
     vector&lt;Rect&gt; rectVec;
  };
  </code></pre>
  
  <p>My question is how can I return a 'read-only' copy of my Vector?
  I am thinking of doing this:</p>
  
  <pre><code>class A {
  public:
    const vect&lt;Rect&gt;&amp; getRectVec() { return rectVect; }
  }
  </code></pre>
  
  <p>Is that the right way? 
  I am thinking this can guard against the callee modify the vector(add/delete Rect in vector), what about the Rect inside the vector?</p>