#include using namespace std; class Employee { public: void print() { cout << "I am a mere employee" << endl; } }; class Manager : public Employee { public: virtual void print() { cout << "I am not only an employee, but a manager!" << endl; } }; class UltraManager : public Manager { public: void print() { cout << "I AM SUPER MANAGER" << endl; } }; int main() { Manager *m = new UltraManager(); // Because the Manager class declares print as virtual, this call will use // dynamic dispatch m->print(); Employee *e = m; // Because we've cast all the way up to Employee, which doesn't think print // is a virtual method, this call will use static dispatch e->print(); delete m; return 0; }