Search code examples
c++compiler-warningsmethod-hiding

Clearing out Function Hiding compiler warnings in C++


I'm getting "hiding" warnings in my compiler because a class inherits from its parent has the same name but different parameters.

Adding a function that merely pushes out a warning to say that this function does nothing (as is true in the base class, but without the warning) that matches the parameters and name of the base class function to the derived class clears this compiler warning. What are the potential knock-on effects of this on the derived class?

EDIT: Assume that I do not wish them to be able to use the base class function. (Don't ask).


Solution

  • The inability of your users to access the base class function through a derived instance without explicitly writing out myDerivedObj.Base::foo(), which they're not likely to do.

    Make your function signatures match up, instead, or change the function name.