c++ - Invalid arguments in classes -


char* n=m.getname(); 

i following error invalid arguments ' candidates are: char * getname() ' above instruction.what missing?

char* medicine::getname()  {     return this->name; } 

name of declared char name[50]; andm const medicine& m

if m const, const methods can called on it. maybe can change method to

const char* medicine::getname() const;  

and use this:

const char* n=m.getname(); 

although might consider using std::string data member instead of array of char.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -