Question: (code below) Change the base class and derived class definitions to include the default constructor and an initializing constructor. The parameterized constructors need to initialize

(code below) Change the base class and derived class definitions to include the default constructor and an initializing constructor. The parameterized constructors need to initialize the private members of the respective class.

The derived class constructor needs to accept the initializing values for the base class members as well.

Also, write destructor functions for all base and derived classes. The default constructor and destructor functions dont have to do anything.

In main func:

Create an object each of classes senior and freshman. While creating the objects, call the

parametrized derived class constructors and pass appropriate values. Call the derived class accessor function to get the value of name, id, gpa and respective

scores.

//Include the needed header files #include #include using namespace std;

//Class class Student { //Access specifier public: //Mutator void setVars(); //Accessor void getVars(); //Access specifier private: //Variable for student id unsigned long int id; //Variable for student name string name; //Variable for student gpa double gpa; };

//Definition for Mutator void Student::setVars() { //Variable for student id unsigned long int id; //Variable for student name string name; //Variable for student gpa double gpa; //Prompt for id cout<<" Enter the value of id : "; //Read id cin>>id; //Assign this->id= id; //Prompt for name cout<<" Enter the value of name : "; //Read name cin.ignore(); getline(cin,name); //Assign this->name=name; //Prompt for gpa cout<<" Enter the value of gpa : "; //Read gpa cin>>gpa; //Assign this->gpa=gpa; }

//Definition for Accessor void Student::getVars() { //Display student ID cout<<" ID : "<

//Derived class - Freshman class Freshman: public Student { //Access specifier private: //Variable for score double csce1030; //Access specifier public: //Accessor void getValue(); //Mutator void setValue(); };

//Definition for Accessor void Freshman::getValue() { //Display freshman score cout<<" Score : "<

//Definition for Mutator void Freshman::setValue() { //Prompt for freshman score cout<<" Enter score for freshman: "; //Read freshman score cin>>csce1030; //Assign this->csce1030=csce1030; }

//Derived class - Senior class Senior: public Student { //Access specifier private: //Variable for score double csce4530; //Access specifier public: //Accessor void getValue(); //Mutator void setValue(); };

//Definition for Accessor void Senior::getValue() { //Display senior score cout<<" Score : "<

//Definition for Mutator void Senior::setValue() { //Prompt for senior score cout<<" Enter score for senior: "; //Read senior score cin>>csce4530; //Assign this->csce4530=csce4530; }

//Driver int main() { //Create instance for freshman Freshman f1; //Create instance for senior Senior s1; //Details of freshman cout<<"Freshman"<

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 Databases Questions!