title: Storing Class object in an array
body: <p>Please take a look at the following:</p>
  
  <pre><code>dispenserType type[4];
  dispenserType appleJuice();
  type[0] = appleJuice;
  dispenserType orangeJuice();
  type[1] = orangeJuice;
  dispenserType mangoLassi();
  type[2] = mangoLassi;
  dispenserType fruitPunch();
  type[3] = fruitPunch;
  </code></pre>
  
  <p>as you can see i have stored different objects in the <code>type</code> array.</p>
  
  <p>The <code>dispenserType</code> class has a constructor that sets the number of items to 20.
  so we have <code>int numberfItems</code> for the object <code>appleJuice</code> set to 20 so on and so forth. </p>
  
  <p>The same class has also the following methods: method that decreases the <code>numberOfItems</code> by one:</p>
  
  <pre><code>void dispenserType::makeSale()
  {
      numberOfItems--;
  }
  int dispenserType::getNoOfItems() const
  {
      return numberOfItems;
  }
  </code></pre>
  
  <p>If for example the following is called:</p>
  
  <pre><code>appleJuice.makeSales
  cout &lt;&lt; appleJuice.getNoOfItems() &lt;&lt; endl;
  </code></pre>
  
  <p>then the program would display the right <code>numberOfItmes</code>, which is 19. On the other hand, if <code>cout&lt;&lt;type[0].getNoOfItems()</code> is called, then it would display the number 20. </p>
  
  <p>That behavior leads me to think that <code>appleJuice</code> and <code>type[0]</code> are two separate objects.</p>
  
  <p>My questions is, is there a way to create an array of objects without needing to declare an object and store in an array as I did it as I did?</p>
  
  <p>thank you.</p>