Reputation: 177
When I call getCount function in the below code, QT 4.7.3 complier giving the error. Build Error
pasing 'cont Person' as 'this' argument of 'int Person::getCount(const QString&) discards qualifiers
bool Person::IsEligible(const QString& name)
{
int count = 0;
count = getCount(name);
}
int Person::getCount(const QString& name)
{
int k =0
return k;
}
Upvotes: 3
Views: 2369
Reputation: 88731
The error isn't a problem with passing string arguments, it's that you've got a const
person, e.g.:
const Person p1;
Person p2;
p1.IsEligible("whatever"); //Error
p2.IsEligible("whatever"); //Fine because p2 isn't const
If IsEligible
is meant to be callable on const Person
s then you can say:
bool Person::IsEligible(const QString& name) const
{
int count = 0;
count = getCount(name);
}
(and change the corresponding declaration that you've not shown too obviously), but I'm not 100% sure that's what you intended to do.
Upvotes: 4