Why this friend function can't access a private member of the class?
Posted
by Alceu Costa
on Stack Overflow
See other posts from Stack Overflow
or by Alceu Costa
Published on 2010-03-23T14:29:51Z
Indexed on
2010/03/23
14:33 UTC
Read the original article
Hit count: 184
c++
I am getting the following error when I try to access bins private member of the GHistogram
class from within the extractHistogram()
implementation:
error: 'QVector<double> MyNamespace::GHistogram::bins' is private
error: within this context
Where the 'within this context' error points to the extractHistogram()
implementation. Does anyone knows what's wrong with my friend function declaration?
Here's the code:
namespace MyNamespace{
class GHistogram
{
public:
GHistogram(qint32 numberOfBins);
qint32 getNumberOfBins();
/**
* Returns the frequency of the value i.
*/
double getValueAt(qint32 i);
friend GHistogram * Gbdi::extractHistogram(GImage *image, qint32 numberOfBins);
private:
QVector<double> bins;
};
GHistogram * extractHistogram(GImage * image, qint32 numberOfBins);
}
© Stack Overflow or respective owner