Why this friend function can't access a private member of the class?
<p>I am getting the following error when I try to access bins private member of the <code>GHistogram</code> class from within the <code>extractHistogram()</code> implementation:</p>

<pre><code>error: 'QVector&lt;double&gt; MyNamespace::GHistogram::bins' is private
error: within this context
</code></pre>

<p>Where the 'within this context' error points to the <code>extractHistogram()</code> implementation. Does anyone knows what's wrong with my friend function declaration?</p>

<p>Here's the code:</p>

<pre><code>namespace MyNamespace{

class GHistogram
{

public:
    GHistogram(qint32 numberOfBins);
    qint32 getNumberOfBins();

    /**
     * Returns the frequency of the value i.
     */
    double getValueAt(qint32 i);
    friend GHistogram * MyNamespace::extractHistogram(GImage *image, 
                                                      qint32 numberOfBins);

private:
    QVector&lt;double&gt; bins;
};

GHistogram * extractHistogram(GImage * image, 
                              qint32 numberOfBins);

} // End of MyNamespace
</code></pre>
