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
>Closed-Date:
>Last-Modified:
>Originator:     sawinski@web.de
>Release:        gcc-3.0.3
>Organization:
>Environment:
Linux nc1701d 2.4.18-pre7-ac1 #2 Tue Jan 29 22:21:52 CET 2002 i686 unknown
>Description:
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::".
>How-To-Repeat:
#include <iostream>

using namespace std;

class A
{
public:
  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
{
public:
  void f(int);
};

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

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

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

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list