#include using namespace std ; //Virtual Destructor class Person { public: string firstName ; string lastName ; //virtual void getName() { cout << firstName << " " << lastName << endl ; } Person( string firstNameP ) { firstName = firstNameP ; cout << "Person Constructor." << endl ; } //virtual ~Person() { cout << "Person Destructor." << endl ; } }; class Employee : public Person { public: string jobTitle ; virtual void getName() { cout << firstName << " " << lastName << " " << jobTitle << endl ; } Employee(string firstNameP) : Person( firstNameP ) { jobTitle = "Employee title." ; cout << "Employee Constructor." << endl ; } //virtual ~Employee() { cout << "Employee Destructor." << endl ; } }; class Manager : public Employee { public: //What if the method is missing //Climb up the hierarchy string jobTitle ; virtual void getName() { cout << firstName << " " << lastName << " " << jobTitle << Employee::jobTitle << " Manager" << endl ; } Manager( string firstNameP ): Employee( firstNameP ) { jobTitle = "Manager title." ; cout << "Manager Constructor." << endl ; } //virtual ~Manager() { cout << "Manager Destructor." << endl ; } }; int main() { Person* p1 ; Employee* e1 ; Manager* m1 ; m1 = new Manager( "Chuck" ) ; m1->firstName = "Chuck" ; m1->lastName = "Wepner" ; m1->jobTitle = "Boxer" ; m1->getName() ; //p1 = m1 ; //e1->getName() ; //Make sure we delete the right type //or program will crash delete m1 ; return 0 ; }