// uses the student and compsci classes to demonstrate // simple inheritance and polymorphism #include #include "student.h" #include "compsci.h" #include "bio.h" int main(void) { // create some objects // student joe("Joe Student",88.5); compsci sam("Sam Iam","C C++ Java Perl", 66.2); bio mary("Sue Infection","E-coli Ameboa Dyanictoplasmoticnic",98.4); // here comes poly - create an array of pointers to students, setting // the array to point to the 3 defined above. Since compsci and bio // classes are derived from student, we can do this (we can treat // them as if they were of type students). student *roster[] = { &sam, &mary }; for (int i=0;i<3;i++) { cout << "STUDENT # " << i << endl; roster[i]->print(); cout << endl; } }