I have a program structured similiar to:
class A {
private:
std::set<B> members;
public:
void func(const C& arg) {
std::set<B>::iterator iter = members.find(a);
if(iter != members.end()) {
iter->check(arg);
}
}
}
class B {
private:
std::deque<C> writers;
public:
void check(const C& arg) {
if(std::find(writers.begin(), writers.end, arg) != writers.end()) {
/* Code */
}
}
}
class C {
private:
int id;
public:
bool operator==(const C& arg) {
return arg.id == this->id;
}
}
When I compile this, I get the following error message:
no matching function for call to ‘B::check(const C&) const’
note: candidates are: void B::check(const C&) <near match>
If I declare check()
as const
then the compiler throws an error demanding that the overloaded operator ==
in Class C to be declared as const
. I don't know if making the overloaded operator as const
is the right thing to do. (I tried it once and as far as I can recollect it also gave some error).
I been trying to solve this for more than five days and still no leads.