This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Hi bugmakers
- To: osa at klo dot re dot com dot ua
- Subject: Re: Hi bugmakers
- From: "Martin v. Loewis" <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Fri, 26 Feb 1999 09:48:11 +0100
- CC: egcs-bugs at cygnus dot com
- References: <Pine.BSI.3.91.950221075326.1855A-100000@klo.re.com.ua>
> 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