// try a vector of pointers to Students! #include #include #include using namespace std; class Student{ public: Student(){} string type(){ return "other"; } }; class Undergraduate : public Student{ public: Undergraduate(){} string type(){ return "undergraduate"; } }; class Graduate : public Student{ public: Graduate(){} string type(){ return "graduate"; } }; int main() { vector cs595(3); Student a; Undergraduate b; Graduate c; cout << "a.type() =" << a.type() << endl; cout << "b.type() =" << b.type() << endl; cout << "c.type() =" << c.type() << endl; cs595[0] = &a; cs595[1] = &b; cs595[2] = &c; for(int i=0; i<3; ++i) cout << "cs595["<type() =" <type() << endl; }