/* ------- Hockey Team with a Quarterback ------- */ using namespace std; #include #include class team // super class for teams { public: string name; // name of team }; class hockeyteam : public team { public: string city; string goalie; hockeyteam(string s, string c, string g) {name=s; city = c; goalie=g;} }; class footballteam : public team { public: string quarterback; footballteam(string s, string q) {name=s; quarterback=s;} }; int main(int argc, char** args) { team *A; // a variable with static type "team". if (argc>1) A = new footballteam("NY Jets","some qb"); else A = new hockeyteam("NY Islanders","Uniondale","good goalie"); cout << "The quarterback for the " << A->name << " is " << ((footballteam*)A)->quarterback << endl; return 0; } /* Output (with no command-line argument) The quarterback for the NY Islanders is Uniondale */