How does overload resolution work in the context of private modifier?
I am unable to understand the output of the following C++ snippet. Should not objc.fn() call A 's fn() since B's fn() is private and should not be visible in C . However, the answer is: the call to fn() is ambiguous. How? #include<iostream> using namespace std; 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; } songyuanyao According to the book C++ Templates: The Complete Guide Appendix B.1, At a very high level, a call to a named function can be processed in the following way: The