no matching function for call to... missing overload in inherited C++ class
c++, inheritance, overloading
Solution
Because your overriding of `hello(int arg)` hides other functions with the same name.
What you can do is to explicitly introduce those base class functions to subclass:
struct B : A {
using A::hello; // Make other overloaded version of hello() to show up in subclass.
virtual void hello(int arg) {}
};
Problem
Can someone please explain what's going on here. Why can't the compiler see hello() with no arguments in class A? ``` struct A { virtual void hello() {} virtual void hello(int arg) {} }; struct B : A { virtual void hello(int arg) {} }; int main() { B* b = new B(); b->hello(); return 0; } ``` g++ main.cpp ``` main.cpp: In function ‘int main()’: main.cpp:13:11: error: no matching function for call to ‘B::hello()’ main.cpp:13:11: note: candidate is: main.cpp:7:15: note: virtual void B::hello(int) main.cpp:7:15: note: candidate expects 1 argument, 0 provided ```