I have a base class that has two functions with the same name, but with different signatures in two-level inheritance.
struct A { virtual void f(int) { } virtual void f(int, int) { }; virtual void f1(int) { } }; struct B: public A { }; struct C: public B { void f(int, int) { } void f1(int) { } }; int main() { C obj; obj.f1(0); obj.f(0,0); obj.f(0);
I would expect my compiler (gcc-4.3.2) to find the correct definition in (1) , but I get
g++ main.cpp -o main main.cpp: In function 'int main()': main.cpp:20: error: no matching function for call to 'C::f(int)' main.cpp:10: note: candidates are: virtual void C::f(int, int) distcc[2200] ERROR: compile main.cpp on localhost failed make: *** [main] Error 1
(2) on the other hand works.
What do I need to fix to do the job (1) in general?
c ++ inheritance
Benjamin bannier
source share