keyword "using" in egcs 1.1b
Martin Bachtold
martinb@coyotesystems.com
Tue Oct 6 17:04:00 GMT 1998
Hi,
I'm experiencing what I believe to be a bug in egcs-1.1b under Red Hat
Linux 5.1. The issue is connected to the "using" keyword in the ANSI C++
standard. "Using" should allow to make inherited methods available that
have been overloaded in a derived class, e.g., the simple example:
The file "usingTest.cc"
//------------------------------------------------------------------------------------
#include "iostream.h"
class A {
public:
A() {}
void print() const {cout << "A::print()" << endl;}
};
class B: public A {
public:
B() {}
using A::print;
void print(ostream& out) const {out << "B::print(ostream&)" << endl;}
};
int main(int, char**) {
B b;
b.print();
b.print(cerr);
}
//------------------------------------------------------------------------------------
should provide two overloaded print methods for the derived class B, one
being the inherited method A::print() made available by the "using"
keyword and one being the overloaded B::print(ostream&).
This example fails to compile with egcs 1.1b, resulting in the following
error:
gcc -c -gstabs+3 -fno-implicit-templates -o usingTest.o usingTest.cc
usingTest.cc:14: cannot adjust access to `void A::print() const' in
`class B'
usingTest.cc:13: because of local method `void B::print(class ostream
&) const' with same name
usingTest.cc: In function `int main(int, char **)':
usingTest.cc:18: no matching function for call to `B::print ()'
usingTest.cc:13: candidates are: B::print(ostream &) const
Am I correct that the sample program is legal ANSI C++ and should
compile as described?
Regards, Martin
--
___________________________________________________________________________
Martin Bächtold
Coyote Systems, Inc.
2740 Van Ness Ave. #210, San Francisco, CA 94109
Tel. +1 (415) 346-4223 x14;
Fax. +1 (415) 346-6282; email: martinb@coyotesystems.com
___________________________________________________________________________
More information about the Gcc-bugs
mailing list