overloaded functions are hidden in derived class

TTBOMK this doesn’t have a real technical reason, it’s just that Stroustrup, when creating the language, considered this to be the better default. (In this it’s similar to the rule that rvalues do not implicitly bind to non-const references.)

You can easily work around it be explicitly bringing base class versions into the derived class’ scope:

class base {
public:
  void f(int);
  void g(int);
};

class derived : public base {
public:
  using base::f;
  void f(float);
  void g(float); // hides base::g
};

or by calling the explicitly:

derived d;
d.base::g(42); // explicitly call base class version

Leave a Comment