I wonder why static objects call parent method and dynamic objects child method in this example.
#include <string>
#include <iostream>
using namespace std;
class Father {
public:
virtual string Info() {
return "I am father";
}
};
class Son : public Father {
public:
string Info() {
return "I am son";
}
};
int main() {
Father f = Son();
cout << f.Info(); // I am father
Father* pf = new Son();
cout << pf->Info(); // I am son
return 0;
}