Contents Up << >>

What's the meaning of, "Warning: Derived::f(int) hides Base::f(float)"?

It means you're going to die.

Here's the mess you're in: if Derived declares a member function named "f", and Base declares a member function named "f" with a different signature (e.g., different parameter types and/or constness), then the Base "f" is "hidden" rather than "overloaded" or "overridden" (even if the Base "f" is virtual).

Here's how you get out of the mess: Derived must redefine the Base member function(s) that are hidden (even if they are non-virtual). Normally this re-definition merely calls the appropriate Base member function. E.g.,

  	class Base {
	public:
	  void f(int);
	};

	class Derived : public Base {
	public:
	  void f(double);
	  void f(int i) { Base::f(i); }
 	};             // ^^^^^^^^^^--- redefinition merely calls Base::f(int)
  • Inheritance: Conformance