/* CSE 333 Lecture 19 Peer Instruction Question */
#include <iostream>

using namespace std;

class A {
 public:
  void Foo() { cout << "A" << endl; }
};

class B : public A {
 public:
  virtual void Foo() { cout << "B" << endl; }
};

class C : public B {
};

class D : public C {
 public:
  void Foo() { cout << "D" << endl; }
};

class E : public C {
};


int main(int argc, char** argv) {
  // objects for you to use
  A a;
  B b;
  C c;
  D d;
  E e;

  A* a_ptr = &a;
  cout << "a_ptr -> A:  ";
  a_ptr->Foo();
  a_ptr = &b;
  cout << "a_ptr -> B:  ";
  a_ptr->Foo();
  a_ptr = &c;
  cout << "a_ptr -> C:  ";
  a_ptr->Foo();
  a_ptr = &d;
  cout << "a_ptr -> D:  ";
  a_ptr->Foo();
  a_ptr = &e;
  cout << "a_ptr -> E:  ";
  a_ptr->Foo();
  cout << endl;

  B* b_ptr = &b;
  cout << "b_ptr -> B:  ";
  b_ptr->Foo();
  b_ptr = &c;
  cout << "b_ptr -> C:  ";
  b_ptr->Foo();
  b_ptr = &d;
  cout << "b_ptr -> D:  ";
  b_ptr->Foo();
  b_ptr = &e;
  cout << "b_ptr -> E:  ";
  b_ptr->Foo();
  cout << endl;

  C* c_ptr = &c;
  cout << "c_ptr -> C:  ";
  c_ptr->Foo();
  c_ptr = &d;
  cout << "c_ptr -> D:  ";
  c_ptr->Foo();
  c_ptr = &e;
  cout << "c_ptr -> E:  ";
  c_ptr->Foo();
  cout << endl;

  D* d_ptr = &d;
  cout << "d_ptr -> D:  ";
  d_ptr->Foo();
  cout << endl;
   
  E* e_ptr = &e;
  cout << "e_ptr -> E:  ";
  e_ptr->Foo();
  cout << endl;

  return 0;
}