No overloading of virtual methods allowed within inheritance
Nathan Sidwell
nathan@acm.org
Thu Feb 7 09:06:00 GMT 2002
Stuart Reynolds wrote:
>
> There seems to be a problem overloading
> virtual method names in class hierarchies.
> I'm fairly sure this is a compiler problem -
> not an oversight/feature in the language
> specification (but I could be wrong).
You are wrong, it is how the language is meant to behave. Virtualness
is not the problem, name lookup is.
> class T : public S
> {
> virtual void write(Output& out)
this will hide S::write (ostream &);
you need a using declaration to do what you want.
> t->write(cout); // Error
name lookup only finds T::Write (Output&) as the set of viable
functions within which to do overload resolution.
nathan
--
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
The voices in my head told me to say this
nathan@acm.org http://www.cs.bris.ac.uk/~nathan/ nathan@cs.bris.ac.uk
More information about the Gcc-bugs
mailing list