This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: No overloading of virtual methods allowed within inheritance
- From: Nathan Sidwell <nathan at acm dot org>
- To: Stuart Reynolds <S dot Reynolds at mindlathe dot com>
- Cc: gcc-bugs <gcc-bugs at gcc dot gnu dot org>
- Date: Thu, 07 Feb 2002 16:50:12 +0000
- Subject: Re: No overloading of virtual methods allowed within inheritance
- References: <002a01c1afcc$25613000$0c01a8c0@trinculo>
- Reply-to: nathan at compsci dot bristol dot ac dot uk
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