Slide R-18 // ERROR; can't instantiaten abstract class; class person has // pure virtual method walk() person paula; // OK; freshman is subclass of student student *stu = new freshman(); // OK; statically dispatches to method student::enroll(); if // enroll() were declared virtual in student or a superclass // of student, method freshman::enroll() would have been // called stu->enroll(); // OK; *stu's dynamic type is freshman, which is a // subclass of student; sara gets "student" parts (i.e. not // freshman-specific) of *stu; loss of information student sara = *stu; // OK; statically dispatches to method person::run() because // sara's type is student, and student inherits but does not // override this method sara.run(); // OK; student is a subclass of person; pp now points to // dyn. allocated freshman instance person *pp = stu; // OK; run() declared virtual in person, so dynamically // dispatches to freshman::run() pp->run(); // OK; walk() declared (pure) virtual in person, so // would dynamically dispatch to freshman::walk(), but // freshman doesn't define walk(), so runs inherited // student::walk() pp->walk(); // ERROR; pp is a person ptr., and person is not a subclass // of freshman (and is obviously not the same class, // freshman) freshman *fred = pp; // INVALID; see above fred->enroll();