#include <iostream>
using namespace std;
class A {
public:
virtual void f4() { cerr << "A::f4()" << endl; }
}
class B : public A {
public:
virtual void f4(int n) { cerr << "B::f4(" << n << ")" << endl; }
}
class C : public B {
public:
virtual void f4(int n = 1) { cerr << "C::f4(" << n << ")" << endl; }
}
int main() {
A a;
B b;
C c;
A& rab = b;
A& rac = c;
B& rbc = c;
rab.f4(); rac.f4(); rbc.f4();
}
When i run try to compile this code using rab.f4(); rac.f4(); rbc.f4(); in the main method. rbc.f4() gives me a compiling error and it wont let me. can someone tell me the reason why?