20-CS-122-001 Computer Science II Spring 2012

Virtual functions, classes, inheritance, lists, queues, stacks, applications

inher.cc Simple inheritance
vir0.cc Missing functions in class hierarchy
vir1.cc Effect of virtual methods
visib.cc Visibility of variables and functions in the hierarchy
queue.3.cc A Queue class
queue.3.h A Queue class
vir2.cc Look up then down hierarchy: virtuals everywhere
vir3.cc Look up then down: virtuals at the top and bottom of the hierarchy
vir4.cc Look up then down: virtual only at the top of the hierarchy
vir5.cc Look up then down: virtual in middle of the hierarchy
simple.cc Use of virtual functions to guarantee some method exists for all object types in a Queue
list.cc A List class to support simple above
list.h A List class to support simple above
mult.cc Simple multiple inheritance, demonstrates ambiguities to protect against
student.cc Use class Student : public virtual Person to avoid ambiguity
emp.cc Example of multiple inheritance: an employee database
emp2.cc Add to the above the ability to find employees
topo.no_if.cc    Topological sort with no tests (if, while,...) made possible with virtual functions

Demos:   Inheritance