This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: No overloading of virtual methods allowed within inheritance


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]