Inheritance/Polymorphism  «Prev 

Input Member Function - Exercise

Coding input member functions

Objective: Write input member functions for the student and grad_student classes that read input data for each data member of the respective classes.


Here are the student and grad_student classes for reference:
enum year { fresh, soph, junior, senior, grad };

class student {
   student(char* nm, int id, double g, year x);
   void  print() const;
   int     student_id;
   double  gpa;
   year    y;
   char    name[30];

enum support { ta, ra, fellowship, other };
class grad_student : public student {
      (char* nm, int id, double g, year x, support t,
       char* d, char* th);
   void  print() const;
   support  s;
   char     dept[10];
   char     thesis[80];

This code is also available in a file named student.cpp, which can be found in the compressed course download file available on the Resources page.


Implement student::read and then use it to implement grad_student::read.
Paste the class below and click the Submit button when you are ready to submit this exercise.