C++ Inheritance Demo

This C++ demo shows off inheritance from the abstract class FakeObject to Person. It then shows off regular inheritance from Person to Student.

/*
    Author: Fernando Zamora
    Description:  This code shows off examples of inheritance
    It demonstrates how to override base class methods.
    It also demonstrates implementation of an abstract class (FakeObject)


*/
#include 
#include 
using namespace std;


class FakeObject{
  public:
    virtual void SayType() = 0;  //pure virtual... makes this abstract class
};

class Person: public FakeObject{
  
  protected:
  
    string m_name;

  public:
  
    Person();
    virtual void SayName();
    virtual void SayType();
};


Person::Person(){
  m_name = "Joe Smith";  
}

void Person::SayType(){
  std::cout << "My type is Person" << endl;
}
void Person::SayName(){
      std::cout << "I am a person. My Name is " << m_name  << endl;
}

//Student uses Person as its base class
class Student:public Person{
  
  private:
    string m_university;
    
  public:
    void SayName();
    void SayType();
};

void Student::SayName(){
  std::cout << "I am a student. My Name is " << m_name  << endl;
  std::cout << "I attend " << m_university << endl;
}

void Student::SayType(){
  std::cout << "My Type is Student" << endl;
}

int main() {
  
    Person *p1;
    Person *p2;
    
    p1 = new Student;
    p2 = new Person;
    p1->SayName();
    p2->SayName();
    p1->SayType();
    p2->SayType();
}