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
Post a Comment