我不知道這段代碼有什麼問題。我有以下的,很簡單,等級:靜態類成員獲取「未定義參考」。不知道爲什麼
class SetOfCuts{
public:
static LeptonCuts Leptons;
static ElectronCuts TightElectrons;
static ElectronCuts LooseElectrons;
//***
//more code
};
,例如,類型ElectronCuts在同一個.h文件中之前定義爲:
struct ElectronCuts{
bool Examine;
//****
//other irrelevant stuff
};
沒有什麼太複雜了,我想。
我的理解是,在主程序中,我可以這樣做:
SetOfCuts::LooseElectrons.Examine = true;
,但如果我這樣做,我得到:
undefined reference to `SetOfCuts::LooseElectrons'
相反,如果我做的:
bool SetOfCuts::LooseElectrons.Examine = true;
我得到:
error: expected initializer before '.' token
我不知道爲什麼我不能訪問結構的成員。我錯過了一些關於靜態數據成員的明顯信息,但我不知道它是什麼。
非常感謝。
非常感謝您的回覆。它幫助了很多。 – elelias 2012-04-08 18:32:47