char* n=m.getName();
I get the following error Invalid arguments ' Candidates are: char * getName() '
for the above instruction.What am I missing?
char* Medicine::getName()
{
return this->name;
}
name
is of declared as char name[50];
andm
is const Medicine& m
If m
is const
, then only const
methods can be called on it. Maybe you can change your method to
const char* Medicine::getName() const;
and use it like this:
const char* n=m.getName();
Although you might consider using an std::string
data member instead of an array of char
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With