// File: person3.h // // A simple class derivation. Third version. #ifndef _person_h #define _person_h #include #include #include "bstring3.h" class Person { public: Person() : name(), age(0) {} Person(const BString& bs, int n) : name(bs), age(n) {} virtual void id() { cout << name << " age=" << age << endl ; } BString name ; int age ; // in years } ; class Student : public Person { // public derivation of Person public: Student(const BString& bs, int n, int y, float g) : Person(bs,n), year(y), gpa(g) {} virtual void id() { cout << "Student: " << name << " age=" << age << " year=" << year << " gpa=" << gpa << endl; } int year ; // freshman, sophomore, junior or senior float gpa ; // grade point average } ; class Faculty : public Person { // public derivation of Person public: Faculty(const BString& bs, int n, int y) : Person(bs,n), experience(y) {} virtual void id() { cout << "Faculty: " << name << " age=" << age << " experience=" << experience << endl; } int experience ; // years as faculty } ; #endif