We have the code:
struct B { virtual void f() {} }; struct D : B { void f(int) { } }; int main() { } clang issues a warning to it:
'D::f' hides overloaded virtual function [-Woverloaded-virtual]
Now we make f(int) static in class D :
struct B { virtual void f() {} }; struct D : B { static void f(int) { } }; int main() { } The code is compiled without warning. However, an attempt to use f() on an object of class D :
int main() { D d; df(); } leads to an error:
too few arguments to function call, expected 1, have 0
Those. static f(int) still hides the function from B The problem is solved by adding using B::f; in class D and the code compiles successfully . But the question arises:
Are there any objective reasons not to issue a warning while hiding the B::f() function of a static D::f(int) ?
overrideto avoid it. Even in favor of random hiding, an explicitvirtualcould speak (I don’t have it in the first code example), but if the signatures coincided, it would be implicitly assumed. - αλεχολυτ