#include using std::cout; using std::endl; struct X { virtual void f() { cout << "X::f()" << endl; } }; struct Y : X { virtual void f() { cout << "Y::f()" << endl; } }; int main() { Y* y = new Y(); X* x = y; x->f(); // ohne virtual in X: X::f() y->f(); }