c++/5575: Inheritance of overloaded methods fail.

sawinski@web.de sawinski@web.de
Fri Feb 1 14:06:00 GMT 2002

>Number:         5575
>Category:       c++
>Synopsis:       Inheritance of overloaded methods fail.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 01 14:06:01 PST 2002
>Originator:     sawinski@web.de
>Release:        gcc-3.0.3
Linux nc1701d 2.4.18-pre7-ac1 #2 Tue Jan 29 22:21:52 CET 2002 i686 unknown
If class A defines a couple of overloaded methods (virtual or not), and one inherits this class in another class, let's say B, that redefines one of these methods, the other overloaded methods from A are not accessible anymore without prepending "A::".
#include <iostream>

using namespace std;

class A
  void f();
  void f(int);

void A::f() { cout << "A::f()" << endl; }
void A::f(int) { cout << "A::f(int)" << endl; }

class B : public A
  void f(int);

void B::f(int) { cout << "B::f(int)" << endl; }

main(int argc, const char **argv)
  A a;
  B b;

  b.f();  // <-- compilation fails here: no matching function for call to `B::f()


More information about the Gcc-bugs mailing list