我開始學習C++,但無法解決此錯誤。 我想實現一個名爲IModeloDinamico的類,它具有作爲私有成員在fparser.h庫中實現的稱爲FunctionParser的另一個類的一些對象。 我想實現一些getters,但我有一些錯誤返回其他類的對象。這是代碼。返回其他類的對象的C++類getter錯誤
#//Some includes
#include "fparser.h"
class IModeloDinamico
{
private:
//Some string and double variables.
//FunctionParser variables are objects from fparser library.
FunctionParser fp1;
//...
FunctionParser fp16;
public:
// Constructor
IModeloDinamico();
//Destructor
~IModeloDinamico();
//Accesors
//Getters
//Some getters for string and double vars.
//And getters for return objects of fparser library. **Where i have the errors.**
FunctionParser GetFunctionParser1() const
{
return fp1;
};
FunctionParser GetFunctionParser2() const
{
return fp2;
};
// ...
FunctionParser GetFunctionParser16() const
{
return fp16;
};
//Setters/
// ...
//Some methods..
};
錯誤消息說:
‘FunctionParser::FunctionParser(const FunctionParser&)’ is private.
這種方法在fparser庫中實現,並聲明爲類的私有成員,但我不調用該方法返回的對象。
其他錯誤是:
'within this context'
在FunctionParser的每個獲取。
返回也許你應該參考 – spiritwolfform 2013-05-07 09:48:50
歸還你的職位是非常不可讀。照顧你提問的方式,因爲它會影響答案的質量。這次我爲你編輯了這個問題,下次請自己動手。 – Spook 2013-05-07 09:53:31
謝謝Spook。這是我的第一條消息,我迷路了!下次我會以正確的方式做到這一點。謝謝。 – user2357667 2013-05-07 10:02:09