Adding Functionality to Classes

I'm not grasping how to go about this, any help would be appreciated... thank you!

Exercise 12.0
--- Given a parent class below (Student), derive a child class (UndergradStudent).

The UndergradStudent should have two new members: float engScore, float bioScore.

The UndergradStudent should overwrite getGPA() to take into consideration of two new members.

--- In the main function, create one object of Student and another object of UndergradStudent and
let the two objects to call their own getGPA().

class Student
{
protected:
int ID;
float mathScore;
float chemScore;
public:
Student (int = 0, float = 0.0f, float = 0.0f);
void getGPA();
};

Student::Student (int id, float ms, float cs)
{
ID = id;
mathScore = ms;
chemScore = cs;
}

void Student::getGPA ()
{
float gpa = (mathScore + chemScore)/2.0;
cout << "ID = " << ID << " PGA = " << gpa << endl;
}
Topic archived. No new replies allowed.