我收到以下錯誤任何領域:錯誤:類「軟件」沒有名爲「PTR」
softwarew.hh: In constructor ‘Software::Software(std::string, int)’:
softwarew.hh:26:45: error: class ‘Software’ does not have any field named ‘ptr’
softwarew.hh:28:7: error: ‘ptr’ was not declared in this scope
softwarew.hh: In destructor ‘Software::~Software()’:
softwarew.hh:40:6: error: ‘ptr’ was not declared in this scope
有人能解釋我爲什麼會收到這些錯誤?
會導致該錯誤代碼:
Software(std::string name, int revision) : ptr(software_construct(name.c_str(), revision)) {
if(!ptr) throw std::runtime_error("no software created");
}
~Software(){
if(ptr)
software_destruct(ptr);
}
private:
struct Software_s* ptr;
什麼是'Software_s'? –
這些是* only *錯誤還是警告?你能發佈一個完整的,最小的,可編輯的例子嗎? –
簡單 - 它發生是因爲「軟件類沒有任何名爲'ptr'的字段」 –