//zoo.cpp //test for virtual functions #include "animals.h" main() { Animal *a; Animal *zoo[4]; int i; Cat Barsik; Dog Pif; Cow Liz; Tiger ShereKhan; zoo[0]=&Barsik; zoo[1]=&Pif; zoo[2]=&Liz; zoo[3]=&ShereKhan; cout<<"Welcome to the virtual zoo"<pinch(); a->cry(); // now calling it directly as a Cat Barsik.pinch(); Barsik.cry(); // Same for the dog, first as a type of an Animal a=&Pif; a->pinch(); a->cry(); // Now calling it as a Dog Pif.pinch(); Pif.cry(); // Just check on the other animals // Cow a=&Liz; a->pinch(); a->cry(); // Tiger a=&ShereKhan; a->pinch(); a->cry(); // Now pinch all the animals in the zoo cout << "Now for the whole zoo at once" << endl; for (i=0; i<4; i++){ zoo[i]->pinch(); zoo[i]->cry(); } return 0; }