kanner@Apple.COM (Herbert Kanner) (05/20/89)
This may have already been discussed on the net. I looked for a
while, but couldn't find a reference to the problem. Consider the
following:
class B {
public:
void f();
void f(int);
};
class D : public B {
public:
void f(int);
};
foo()
{
D d;
d.f();
}
Compilation produces the error message:
# error: argument 1 of type int expected for D::f()
What happens is that the overriding is done by name. The appearance of the
name "f" as a member function of D overrides all overloaded instances
of "f" in the base class. This fact has been known to me for some
time, but I have not been able to find any published documentation
about it. What I would like to hear from the AT&T folks is the reason
for this design decision. Is there a good reason why the overriding
could not have been done argument prototype by prototype, so that
d.f() would call the base class instance without the necessity of
writing B::d.f()?
--
Herb Kanner
Apple Computer, Inc.
{idi,nsc}!apple!kanner
kanner@apple.com