I always thought public methods of base class do get inherited by the derived class, even thought the derived class did not had definition of that particular method. For example
#include <iostream>
using namespace std;
class A {
public:
int f() { cout << 3; return 0;}
int f(int x) {cout << x; return 0;}
};
class B: public A {
public:
int f() {std::cout << 5; return 0;}
};
int main(){
B ob;
ob.f(7);
return 0;
}
I was expecting the result to be : 7 , but I get compilation error saying
" error: too many arguments to function call, expected 0, have 1; did you mean 'A::f'?"
I know what the error is trying to say but I am little confused that the fuction from the Base class is not called.