title: Iterating through base class member
body: <p>I have the something like the following:</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;iostream&gt;
  
  template&lt;typename T&gt;
  class Vector {
  private:
    std::vector&lt;T&gt; base;
  
  public:
    Vector(const std::vector&lt;T&gt; vec) {base = vec;}
  
    T&amp; operator[](const int&amp; index) {return base[index];}
    std::vector&lt;T&gt; getBase() const {return base;}
  };
  
  
  class BigNum : public Vector&lt;int&gt;
  {
  public:
    BigNum(const std::vector&lt;int&gt; init) : Vector(init) {}
  };
  
  
  int main()
  {
    int arr[] = {6,3,7,6,2};
    std::vector&lt;int&gt; v(arr, arr + sizeof(arr) / sizeof(arr[0]));
  
    BigNum num(v);
  
    for(auto it = num.getBase().begin(); it != num.getBase().end(); ++it)
      {
        std::cout &lt;&lt; *it &lt;&lt; " ";  // What's going on here??
      }
  
    std::cout &lt;&lt; "\n";
  
    for(int i = 0; i &lt; 5; ++i)
      {
        std::cout &lt;&lt; num.getBase()[i] &lt;&lt; " ";
      }
  
    std::cout &lt;&lt; "\n";
  }
  </code></pre>
  
  <p>The output of these two loops is:</p>
  
  <pre><code>30134336 0 7 6 2 
  6 3 7 6 2 
  </code></pre>
  
  <p>What's going on here?  The first number in the first loop (30134336) changes every time, but the remaining numbers are the same.  Thanks in advance!</p>