#include #include "student.h" // illustrate inheritance class DukeStudent : public Student { public: DukeStudent(const string & name); virtual void Play(); // new for Duke students virtual void Eat(); virtual void BeAlive(); }; DukeStudent::DukeStudent(const string & name) : Student(name) { } void DukeStudent::Play() // post: student has played, loses inergy { myEnergy -= 10; cout << "work hard/play hard" << endl; } void DukeStudent::Eat() { cout << "food at Mongolian Grill?" << endl; Student::Eat(); } void DukeStudent::BeAlive() { Student::BeAlive(); Play(); } void DoSchool(Student & s) // { while (s.IsAlive()) { s.BeAlive(); cout << endl << s.Name() << ": energy = " << s.Energy() << endl; } } int main() { Student normal("Pat"); DukeStudent super("Chris"); DoSchool(normal); DoSchool(super); return 0; }