Overloading '<<' so it is usable with more than one object
<p>I'm starting to get a grasp of operator overloading but I've hit a wall. I cant figure out how I would make '&lt;&lt;' work the way it is redefined to work with more than one type of object from my class. I have to use one of my class constructors to initialize two separate matrices so I need to make two different objects like so: matrix a(sizeIn, rangeIn), b(sizeIn, rangeIn); but as you can see below my '&lt;&lt;' overloading function only uses one class parameter. Can anyone help me out?</p>

<pre><code>ostream &amp; operator &lt;&lt; (ostream &amp; os, const matrix &amp; a)
{
    for (int i = 0; i &lt; a.size; i++)

    {
        cout &lt;&lt; '|';
        for (int j = 0; j &lt; a.size; j++)
            {
            os &lt;&lt; setw(4) &lt;&lt; a.array[i][j] &lt;&lt; " ";
            }
        os &lt;&lt; setw(2) &lt;&lt; '|' &lt;&lt; endl;
    }
    return os;
}
</code></pre>
