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]

Re: Hi bugmakers


> There is something wrong in my code ?
> Base class has two virtual functions with diffrent parametrs, and
>   in overloading on of them, i lost second.... is it ok ?

Yes. A method declaration in a derived class hides all method
declarations in the base class with the same name, whether they are
virtual or not. The standard says, in 3.3.7 Name hiding

>> A name can be hidden by an explicit declaration of that same name
>> in a nested declarative region or derived class (10.2).

The base class method is still there, it is just hidden. There are
different ways to call it:

a) explicitly:  b.A::func ( 0, 0 ) ;
   This would be non-virtual.
b) by upcast:   static_cast<A&>(b).func ( 0, 0 ) ;
   This considers virtuality.

There is a third option: with a using-declaration, you could make the
methods visible in B. Due to a bug in g++, this doesn't currently
work.

If you still don't understand, please read have a look in the
Stroustrup book, or ask in comp.lang.c++.

Thanks,
Martin


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