OOPortal OOPortal


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.

Background


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

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

enum support { ta, ra, fellowship, other };
class grad_student : public student {
public:
   grad_student
      (char* nm, int id, double g, year x, support t,
       char* d, char* th);
   void  print() const;
protected:
   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.

Instructions

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.