CS3240: Data Structures and Algorithms

Exercise: Creating a subclass

Not Collected

Below is a class called Student. The class Student is a generic class that lists information about the student. You are to design and create two sub-classes of Student called: Undergrad and Graduate.

The class Undergrad should contain:
  • Capstone = title of capstone project.
  • Internship = Numer of internships that student has performed.
  • anything elese you think is appropriate.
The class Graduate should contain:
  • Thesis = title of thesis.
  • Papers = Numer of papers the student has published.
  • anything elese you think is appropriate.
You should have both the Undergrad and Graduate class over-ride the PrintInfo() member function of the Student class they inherit. In each case, the new PrintInfo function should first invoke its parent's PrintInfo function and then printout only the information that is unique to its class.


You must also create a program called School which has a main() function that creates a few Undergrad and Graduate objects and after setting information prints outs this information to the screen.
class Student {





 public:

    String Name;

    int age;

    int SSNum;

    String Advisor;

    void PrintInfo();



}

    





//now in Student.cpp file

void Student::PrintInfo(){

     cout << "Name: " << Name << endl;

     cout << "age: " << age << endl;

     cout << "SS#: " << SSNum << endl;

     cout << "Advisor: " << Advisor << endl;

}

     

© Lynne Grewe