我收到以下錯誤,當我嘗試從extractHistogram()
執行中訪問箱的GHistogram
類的私有成員:爲什麼這個朋友功能無法訪問班級的私人成員?
error: 'QVector<double> MyNamespace::GHistogram::bins' is private
error: within this context
凡「這個範圍內」的錯誤指向extractHistogram()
實施。有人知道我的朋友函數聲明有什麼問題嗎?
下面的代碼:
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<double> bins;
};
GHistogram * extractHistogram(GImage * image,
qint32 numberOfBins);
} // End of MyNamespace
是'Gbdi'類或命名空間?你有'Gbdi :: extractHistogram'作爲朋友。 – quamrana 2010-03-23 14:32:11
對不起,用MyNamespace替換Gbdi。 GBDI是我工作的研究組的名稱... – 2010-03-23 14:36:37