title: C++ - Basic Error with Arrays of Base Classes
body: <p>I am a bit stuck right now. I have a base class called BaseBond. ZeroCouponBond and CouponBond inherit from that class. I am looking to create an array that contains both types of bonds. Here is my code:</p>
  
  <pre><code>...
  BaseBond port[12];
  
  for (int i=0; i &lt; recordCount; i++)
  {
      if (bonds[i].CouponRate == 0.0)
          port[i] = new ZeroCouponBond(bonds[i]);
      else
          port[i] = new CouponBond(bonds[i]);
  }
  </code></pre>
  
  <p>Here is the error I am getting:
  error: no match for ‘operator=’ in ‘port[i]</p>
  
  <p>I know this is probably a simple fix and has to do with when I can declare objects in an array, but I'm relatively new to C++ and don't know all the rules. </p>
  
  <p>Thanks in advance for the help!</p>