我有以下的結構,主要宣佈(沒關係成員!):結構作爲構造函數的參數(在主申報)
struct args
{
std::vector<string> names;
std::vector<std::shared_ptr<RegularExpression>>vreg;
std::vector<string> stopFile;
std::vector<string> groundTruth;
int debug;
};
,我有一個CLASSE驗證這需要ARGS作爲構造函數的參數
#ifndef VERIFICATION_H
#define VERIFICATION_H
class Verification
{
public:
Verification(std::string, std::vector<double>,double,args);
private:
args _A;
}
#endif // VERIFICATION_H
現在主:
struct args
{
std::vector<string> names;
std::vector<std::shared_ptr<RegularExpression>>vreg;
std::vector<string> stopFile;
std::vector<string> groundTruth;
int debug;
};
int main()
{
Verification v("res.cr",gt, 0.75,A);
return 0;
}
我有以下的編譯錯誤:
- Verification.h | 33 |錯誤: 'ARGS' 沒有指定類型| (這個錯誤是針對班級_A中的私人成員的)
- main.cpp | 153 |錯誤:沒有匹配函數調用'Verification :: Verification(const char [7],std :: vector &,雙,參數&)'|
- Verification.h | 24 |錯誤:'args'尚未聲明| (此錯誤是構造函數)
如何使用主聲明爲驗證類構造函數的參數結構?
謝謝。
偏離主題,但不應該像'_A'那樣使用[保留名稱](http://stackoverflow.com/questions/228783)。 –
噢,是嗎?而愚蠢的我,我認爲我做了正確的事情大聲笑。我有一個法國公司的概述,在他們的代碼中,他們做的和我一樣。 我甚至問他們爲什麼你沒有構造函數和複製構造函數,這是C++中的經驗法則。 她回答說:NAAAAAAAAAAAAAA我們不需要它。殺死我 –