title: NULL data stored by overloaded istream
body: <p>This is part of my polynomial.cpp to get terms by overloading istream</p>
  <pre><code>void Newterm(float coef, int deg) {
          if (terms == capacity) {
              capacity *= 2;
              Term* tmp = new Term[capacity];
              copy(termArray, termArray + terms, tmp);
              termArray = tmp;
              delete[] tmp;
          }
          termArray[terms].degree = deg;
          termArray[terms++].coef = coef; 
      }
  friend istream&amp; operator &gt;&gt; (istream&amp; is, Polynomial&amp; pl) {
          cout &lt;&lt; &quot;number of terms : &quot;;
          int t; is &gt;&gt; t;
          cout &lt;&lt; endl;   
      float coeff;
      int degree;
          for (int i = 0; i &lt; t;i++) {
              cout &lt;&lt; i + 1 &lt;&lt; &quot;'s term: &quot;;
        is &gt;&gt; coeff &gt;&gt; degree;
              pl.Newterm(coeff, degree);  
          }
          return is;
      };
  </code></pre>
  <p><img src="https://i.stack.imgur.com/xHB14.png" alt="this is input and output
  but the printed result(not posted printfunc) says NULL stored in term" /></p>
  <hr />
  <p>of course, i tried to figure out whaaat made this result..
  tried:</p>
  <ol>
  <li><p>removing 'for' loop</p>
  <ul>
  <li>this actually worked.. but it only works when terms=1</li>
  </ul>
  </li>
  <li><p>firstly creating term and input data</p>
  <ul>
  <li><code>Newterm(0,0);</code>
  <code>is&gt;&gt;pl.termArray[i].coef&gt;&gt;pl.termArray[i].degree;</code></li>
  <li>it couldn't fix anything...</li>
  </ul>
  </li>
  </ol>
  <hr />
  <p>so i think it has to do with loops..
  but whyyyy?</p>