This following not compile with (GCC) 4.8.2. It complains like this:
error: no matching function for call to ‘classderivedderived::dump(int)’
#include <iostream>
class classbase{
public:
void print() {std::cout << "base\n";}
virtual void dump() = 0;
void dump(int i) {std::cout << i << " blech\n";}
int i;
};
class classderived : public classbase {
public:
int ii;
};
class classderivedderived : public classderived {
public:
void dump() {std::cout << "blah\n"; dump(10);}
int iii;
};
int main() {
classderivedderived yellow;
yellow.i = 5;
yellow.dump();
}
It does compile and run if
(1) dump(10) => classbase::dump(10)
OR
(2) dump(10) => puddledump(10) and void dump(int i) => void puddledump(int i)
Should this be happening? Why cannot gcc resolve the function call dump(10)
on the
basis of the argument type, as it would for any other function call? I thought that
it would resolve that call because dump(int)
is a member function of classderived
by virtue of begin a member of classbase.