c++ - error: class ‘Software’ does not have any field named ‘ptr’ -


i getting following errors:

softwarew.hh: in constructor ‘software::software(std::string, int)’: softwarew.hh:26:45: error: class ‘software’ not have field named ‘ptr’ softwarew.hh:28:7: error: ‘ptr’ not declared in scope softwarew.hh: in destructor ‘software::~software()’: softwarew.hh:40:6: error: ‘ptr’ not declared in scope 

can explain why receive these errors?

the code causes errors:

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; 

your error says

"class software not have field named ptr"

given suitable definitions of software_s, software_construct, , software_destruct, making sure put field inside class works:

#ifndef softwarew_included #define softwarew_included  class software{   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; };  #endif 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -