@songyuanyao.
++.
, :
Suppose access specifiers do not allow a function to participate in overload resolution, and then:
class A{
public:
void fn() { cout << "1"; }
};
class B{
void fn() { cout << "2"; }
};
class C: public A, public B {};
int main(){
C objc;
objc.fn();
return 0;
}
Now we modify the code:
class A{
void fn() { cout << "1"; }
};
class B{
public:
void fn() { cout << "2"; }
};
Nothing else was affected, and suddenly
objc.fn(); // B::fn() is being invoked
The subscriber of your function does not know that its basic function is no longer the same.
This is blasphemy!
To prevent all such failures, the standard committee adopted this design decision.
source
share