Bug: Failure to compile legal code (gcc-2.95.2)

Loren James Rittle rittle@latour.rsch.comm.mot.com
Wed Jan 17 07:00:00 GMT 2001


Hi Mike,

Alexandre Oliva gave you the right answer.  In your example, the
declaration of B::operator<<(int) does indeed hide A::operator<<(const
char*).  The fact that it is a virtual method means nothing.

In ISO C++, you are suppose to be able to do this:

[...]

class B : public A
{
public:

  using A::operator<<;
  virtual A& operator<<(int);
};

[...]

to ensure that overloading works as you had expected.  However, 2.95.2
doesn't implement that form of using.  g++ 3.0 gets this right.

If you really want to understand why this works this way, see _The
Design and Evolution of C++_. pg 76.  I'm sure that other great tomes
from Stroustrup reveal this information as well.

Regards,
Loren


More information about the Gcc-bugs mailing list