我收到以下错误:
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;