TITLE: Inheritance is not overloading! PROBLEM: Derek R. Marsano (drm@cats.com) Here's a strange behavior from the Sun C++ 2.1 compiler. Class A defines two virtual functions which overload the name 'foo'. Class B, derived from A, overrides one of these virtual functions. The compiler complains that B::foo() hides BOTH of the A::foo() implementations (not just the foo(int) implementation we intend to override). We aren't sure what the language specification says about this, and so we aren't sure whether the Sun compiler has a bug or not. Any ideas? RESPONSE: Robert C. Martin (rmartin@rational.com) This is not a bug, it's a "feature". Two functions can be overloaded only if they are in the same scope. i.e. if f(double) and f(int) are defined in the same scope, then they are overloaded. Functions in a derived class are not in the same scope as the functions in the base class. Thus a function in a base class cannot by overloaded with a function in a derived class. Instead the derived function hides all base functions of the same name. Thus: class X { f(int); f(double); }; class Y : public X { f(int); // hides all the f functions in X }; The ARM in 13.1 goes on to explain why this was thought to be a good idea. Perhaps its is, but overloading base functions seems like a natural operation to me and I have gritted my teeth several times over the inability to do it.