请帮我找出背后的原因:
#include <iostream>
using std::cout;
class A {
public:
virtual void fun(int a = 5) { cout<<a; }
};
class B::public A {
public:
void fun(int a = 10) {
cout<<"Inside A::B::fun().\n";
cout<<"\n"<<a;
}
};
int _tmain(int argc, _TCHAR* argv[]) {
A *obj = new B();
obj->fun();
reutrn 0;
}
虽然它正在调用 B::fun(),但仍然打印 5,为什么以及如何工作。?