I'm trying to call a function on a polymorphic item. But I get the following error message at compile time:
'
this
' argument to member function 'select
' has type 'const SelectParam
', but function is not markedconst
the error is shown at the p->selection(*it)
std::set<Tuple>::iterator it;
for (it = tuples.begin(); it != tuples.end();) {
for (const SelectParam* p: selectionParams) {
bool successful = p->select(*it);
if( !successful ) {
it = tuples.erase(it);
} else {
it++;
}
}
}
and here's how those classes are defined. (I use to not have all the const and & is there but I put them everywhere I could in hopes that I would make whatever it wanted const but clearly I'm not approaching the problem right since it's not changing anything.
In one of the child classes that is being stored at parent pointer.
bool const select(Tuple const & tup) {
bool matched = false;
if (tup[idx] == val) {
matched = true;
}
return matched;
}
In the other child class that is being used with polymorphism
bool const select(Tuple const & tup) {
bool matched = false;
if (tup[idx1] == tup[idx2]) {
matched = true;
}
return matched;
}
And finally here's the parent class that's super simple.
class SelectParam {
public:
virtual const bool select( Tuple const & t) = 0;
};
Thanks in advance for being willing to help my feeble brain.