I don't understand why I have this error error: no matching function for call to ‘Child::m(Mother&)
when I try to compile my code.
From what I understand:
since the type of c is Child
and Child::m have a parameter of type Child
while m is of type Mother
in c.m(m)
then it's the function m() from the Mother class who need to be called.
class Mother{
public:
void m(const Mother&) {
}
};
class Child: public Mother{
public:
void m(const Child&) {
}
};
int main() {
Mother m;
Child c;
c.m(m);
}