I am writing a code and this is a small part of a method i want to implement in a class that inherits from a base class:
const string & getType() const override {
this->type = "Greedy";
return type;
}
and this is the private part of the class:
private:
const string type;
};
Also this is the method im overriding:
virtual const string & getType() const = 0;
when I try to compile the project i get the message:
passing (something) as 'this' argument discards qualifiers
I have seen similar questions but all of them did not have const
in the class method that this message was appearing on. Here is a good example of one:
error: passing xxx as 'this' argument of xxx discards qualifiers
Where seems to be the problem?
Thanks