Question: C + + The Student class defines the strings studentName and studentSSN as protected data members. A constructor has arguments that initialize the data. The

C++
The Student class defines the strings studentName and studentSSN as protected data members. A constructor has arguments that initialize the data. The class StudentAthlete is derived from the Student class and has a private member variable studentSport, which describes the sport the student plays. Both classes have a member function, identity(). The base class Student outputs the student information in the form:
student: studentName SSN: studentSSN
The identity() function in the base class should support polymorphism and should be overridden in the derived class to add the information - Sport: studentSport. Finally, the class StudentWorker is also derived from the Student class and includes the data member studentDept, which describes the department where the student works. The identity() function for this class should report the student name, the student's social security number, and the department where the student works.
Define these three classes and write a test program that creates an array of one Student object, one StudentAthlete object, and one StudentWorker object. In a loop, execute the identity() function for each object so that the information for each object is displayed.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!