Topic: Overloading rules and virtual functions
Author: bill@amber.csd.harris.com (Bill Leonard)
Date: 4 Dec 1992 16:05:34 GMT Raw View
I would like to "reopen" a topic that has been discussed in this group
before, hopefully adding some new information and insights. I'm talking
about the ARM rules regarding overloading functions in different scopes.
First, some background. The ARM says that in the following:
class A1 {
int foo(void) ;
...
} ;
class A2 : public A1 {
int foo(int) ;
...
} ;
A1::foo is not visible in class A2 because A2::foo overloads A1::foo, but
they are defined in different scopes. Okay so far, I have no quibble with
this. However, the same rule says (or is interpreted to say) that in:
class A1 {
virtual int foo(void) ;
virtual int foo(int) ;
...
} ;
class A2 : public A1 {
virtual int foo(int) ;
...
} ;
A1::foo(void) is not visible in A2. This is where my problem comes in. My
C++ compiler (AT&T cfront 2.1) gives warnings when I do things like this,
which seems pretty stupid. I'm not *adding* any new function signatures to
A2, I'm only trying to override a virtual function from the base class. It
does not seem reasonable to me that class A2 should have to override
*every* version of foo that is defined in the base class, even when it only
wants to change the behavior of one of them.
It would seem reasonable to me, therefore, that the rules on overloading
should not apply when a class is *overriding* a virtual function that was
already defined in the base class. (If A2 were trying to define a new
version of foo, I could understand making that hide the other versions.)
What do others think?
--
Bill Leonard
Harris Computer Systems Division
2101 W. Cypress Creek Road
Fort Lauderdale, FL 33309
bill@ssd.csd.harris.com
---------------------------------------------------------------------------
Prism: A place for light waves that commit minor refractions.
---------------------------------------------------------------------------