title: How to iterate through vector passed as pointer
body: <p>My question is in comment in below code.</p>
  
  <pre><code>void printVec(std::vector&lt;int&gt; *myVec) {
  
   // How to do such looping not to dereference pointer
   for (int i = 0; i &lt; myVec-&gt;size(); i++) {
     std::cout &lt;&lt; myVec-&gt;[i] &lt;&lt; " ";
   }
  }
  </code></pre>