I have the following:
class Parent {
public:
virtual bool foo(vector<string> arg1, vector<string> arg2) = 0;
};
class Child : public Parent {
public:
bool foo(vector<string> arg1, vector<string> arg2);
};
// arg1 and arg2 not used - GIVES WARNING
bool Child::foo(vector<string> arg1, vector<string> arg2) {
return false;
}
There is no Parent implementation of foo(…) because it is a pure virtual function. The parent says that foo takes two vector arguments. The child implements it correctly with two string arguments but they’re not used. HOWEVER, some children of Parent WILL use these arguments so they need to always be there.
Is there any way I can use overloading to allow foo in the given Child class not to have the arguments even though the parent says it has to?
Many thanks.
Don’t specify the parameter names:
That should solve the warnings.
If your compiler for whatever reason doesn’t support it – do this: