Calling overrided virtual function instead of overloaded
问题 Say i have this part of code: #include<iostream> using namespace std; class A { public: virtual int f(const A& other) const { return 1; } }; class B : public A { public: int f(const A& other) const { return 2; } virtual int f(const B& other) const { return 3; } }; void go(const A& a, const A& a1, const B& b) { cout << a1.f(a) << endl; //Prints 2 cout << a1.f(a1) << endl; //Prints 2 cout << a1.f(b) << endl; //Prints 2 } int main() { go(A(), B(), B()); system("pause"); return 0; } I can