void f()
{}
struct A
{
void f()
{}
};
struct B : A
{
B()
{
f(); // A::f() is always called, and ::f is always ignored
}
};
int main()
{
B();
}
As the class B's designer, I MIGHT NOT know the fact that B's base class, i.e. A, has a member function A::f, I just know ::f, and call ::f is just what I want.
What I expects is the compiler gives an error because of ambiguity of calling f. However, the compiler always chooses A::f and ignore ::f. I think this might be a big pitfall.
I just wonder:
Why does the overload resolution of member functions exclude the global functions?
What's the rationale?