C++ templates and friend declaration
<p>Can someone tell me whats wrong with my code. I'm guessing that I didn't overload <code>&lt;&lt;</code> correctly, but I'm not sure how to fix it.</p>

<p>The below code implements a simple Stack container. It fails at <code>cout &lt;&lt; si;</code></p>

<p><strong>update:</strong> Made suggested changes, still not compiling.</p>

<p><strong>update2:</strong> Got it! Thanks!</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

template &lt;typename T = int, int N = 10&gt;
struct Stack
{
    T elems[N];
    unsigned int size;

    Stack()
    {
        size=0;
    }

    void push(T e)
    {
        elems[size]=e;
        size++;
    }

    T pop()
    {
        size--;
        return elems[size];
    }

            template &lt;typename T, int N&gt;
    friend ostream&amp; operator &lt;&lt; (ostream&amp; os, const Stack&lt;T, N&gt; &amp;stack);
};

template &lt;typename T, int N&gt;
ostream&amp; operator &lt;&lt; (ostream&amp; os, const Stack&lt;T, N&gt; &amp;stack)
{
    for (unsigned int i=0; i&lt;N; i++)
    {
        os &lt;&lt; stack.elems[i];
    }

    return os;
}


int main()
{   

    Stack&lt;&gt; si;
    si.push(3);
    cout &lt;&lt; si;

}
</code></pre>
