Calling an overloaded friend ostream insert operator with object from pointer array returns memory address
<p>This is my first question on here so bare with me.</p>

<p>I have written an overloaded insert operator which returns all data of an object. For some reason when I am trying to call it ie. cout &lt;&lt; *pkgArray[index] it is displaying nothing, but if I do it without the * it returns a memory address. Below is the overloaded operator and my attempt to use it.</p>

<pre><code>ostream&amp; operator&lt;&lt;(ostream&amp; o, const OverNight&amp; bObj) {
  stringstream ss;
  ss &lt;&lt; bObj.getAddress() &lt;&lt;  ", " &lt;&lt; bObj.getCity() &lt;&lt; ", " &lt;&lt; bObj.getState() &lt;&lt; ", "     &lt;&lt; bObj.getZip();
  string fullAddress = ss.str();
  ss.str("");
  int newWeight = bObj.getWeight();
  ss &lt;&lt; "$" &lt;&lt; bObj.getUnitPrice() + bObj.getAdditional() &lt;&lt; "/ounce";
  string costPerOunce = ss.str();
  o &lt;&lt; left 
      &lt;&lt; setw(1) &lt;&lt; "|"
      &lt;&lt; setw(20) &lt;&lt; bObj.getsname() 
      &lt;&lt; setw(1) &lt;&lt; "|"
      &lt;&lt; setw(20) &lt;&lt; bObj.getName() 
      &lt;&lt; setw(1) &lt;&lt; "|"
      &lt;&lt; setw(60) &lt;&lt; fullAddress 
      &lt;&lt; setw(1) &lt;&lt; "|" 
      &lt;&lt; setw(10) &lt;&lt; bObj.getType()
      &lt;&lt; setw(1) &lt;&lt; "|"
      &lt;&lt; setw(10) &lt;&lt; costPerOunce
      &lt;&lt; setw(1) &lt;&lt; "|"
      &lt;&lt; endl;
  o &lt;&lt; left &lt;&lt; "+" &lt;&lt; setfill('-') &lt;&lt; setw(136) &lt;&lt; right &lt;&lt; "+" &lt;&lt; endl;
  o &lt;&lt; setfill(' '); // clears the hyphen filler.
  return o;
  } 

int main() {
    Package *pkgArray[15]; // package class is abstract.
    OverNight *onObj; // assigned to pkgArray later on.
    TwoDay *tdObj; // assigned to pkgArray later on.


    // pkgArray is a pointerArray filled with objects of 2 derived classes.
    for (int index = 0; index &lt; max; index++) {
        cout &lt;&lt; pkgArray[index];
    }
}
</code></pre>

<p>I have tried *pkgArray[index], and &amp;pkgArray[index], the latter returns a memory address, and the first one returns nothing. I am fairly new to c++ and feel like i've tried everything to work out this issue. Any guidance would be greatly appreciated.</p>

<p>Thank You</p>

<p><strong>EDIT: I have added the declaration of pkgArray and the objects which get assigned to it. I am unable to use vectors as per the assignment.</strong></p>

<p>After looking further into the problem I have discovered what is happening, is the overloaded operator is not picking up on the object being passed. I have tried dereferencing  pkgArray, and finished functionality of the overloaded insert operator in the base class, which works. Now my problem is I need to get the object of the derived class out of the dynamic array. I have tried applying precedence while dereferencing to no avail. Again the declarations are as follows.</p>

<p>OverNight * onObj; // pointer that will be assigned object of derived class.
TwoDay * tdObj; // pointer that will be assigned object of derived class
Package * pkgArray[15]; // this is a dynamic array of type Package which is the base class</p>

<p>After OverNight Objects, and TwoDay Objects are created they are assigned to the Package array.</p>

<p>I am trying to run a loop which calls the overridden &lt;&lt; operator with the derived object that is stored in the dynamic array. I have learned alot throughout my struggles on this task, but apparently not enough yet to fix the issue.</p>

<p><strong>I was able to solve this problem on my own, I will answer my own question in 3 hours when I am allowed to.</strong></p>
