title: How to overload >> operator to take variable argument list
body: <p>I'm looking to overload a '>>' operator such that someone can enter any number of values. </p>
  
  <p>This is the requirement verbatum from the assignment I'm working on: </p>
  
  <blockquote>
    <p>Operator>> should expect to see input in the following form: d v1 v2 …
    vd , where d is the dimensionality of the vector and each vi is the
    value corresponding to index i in the vector.</p>
  </blockquote>
  
  <p>The way I assume it would work would be that the first value would be the size of the array (contained in object Vex), and the rest would be elements. So if they were to type in </p>
  
  <pre><code>Vex vX;
  4, 1, 2, 3, 4 &gt;&gt; vX; 
  </code></pre>
  
  <p>vX would create a dynamic array of size 4 containing the numbers 1-4. </p>
  
  <p>The main part I'm hung up on is how to program the >> overload because there will be a variable number of arguments. </p>
  
  <p>Ideally I would have a solution to the effect of... (this is just an example):  </p>
  
  <pre><code>std::istream&amp; Vex::operator&gt;&gt;(istream&amp; is, const Vex&amp;){
     /*
       Assume int * data has been previously declared in constructor
       data = new int[iterator[0]]
       create iterator of input for istream
       For n from 1 to iterator[0]...
           data[n] = iterator[n] 
     */
  }
  </code></pre>
  
  <p>I just don't know exactly how to do that. I've been looking around and I've found istream_iterator, but I can't find any good examples of someone using it in the way I need to use it. </p>
  
  <p>I hope the info I've provided is enough to answer the question. Please let me know if not.</p>
  
  <p>Thank you very much for your time. </p>