Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please read the above assignment and use this code to create the polymophic poin

ID: 3548675 • Letter: P

Question

please read the above assignment and use this code to create the polymophic pointer. Answer with comments please, thank you

In Module 08 Programming Assignment - Inheritance Proved, you created a program for a class person and a class student. Take this same class person and class student and create a test program that uses a polymorphic pointer p lndividual. Be careful to add the virtual keyword only where required. #include #include using namespace std; class Person { public: all variables here are public and only declared inside the person class string name; string address; string city; string state; int PhoneNumber; void Setter(); void Getter(); }; class Student, public Person { // the student class inherits the person class so any public variable inside the person class v public: int Grade; string Course; float GPA; void Setter(string name, string address, string city, string state, int PhoneNumber, int Grade, string Course, float GPA){ this -> name = name; this -> address = address; this -> city = city; this -> state = state; this -> PhoneNumber = PhoneNumber; this -> Grade = Grade; this -> Course = Course; this -> GPA = GPA; } void Getter () { // gets variables cout

Explanation / Answer

#include<iostream>
#include<string>
using namespace std;

class Person
{
public:
string name;
string address;
string city;
string state;
int PhoneNumber;

void Setter();
virtual void Getter()
{
cout <<"Name :" << name << endl;
cout <<"Address :" << address << endl;
cout <<"City :" << city << endl;
cout <<"State :" << state << endl;
}
};

class Student:public Person
{
public:
int Grade;
string Course;
float GPA;

void Setter(string name,string address,string city,string state,int PhoneNumber, int Grade,string Course,float GPA)
{
this->name = name;
this->address = address;
this->city = city;
this->state = state;
this->PhoneNumber = PhoneNumber;
this->Grade = Grade;
this->Course = Course;
this->GPA = GPA;
}
void Getter()
{
cout <<"Name :" << name << endl;
cout <<"Address :" << address << endl;
cout <<"City :" << city << endl;
cout <<"State :" << state << endl;
cout << "Phone Number :" << PhoneNumber << endl;
cout <<"Grade :" << Grade <<endl;
cout << "Course :" << Course <<endl;
cout <<"GPA :" << GPA << endl;
}
};

int main()
{
//CREATE STUDENT OBJECT.
Student SO;
SO.Setter("bobdole","203 windchest ave","Houston","TX",24983534,11,"Math",3.45);
// declare polymorphic pointer pIndividual
Person* pIndividual = NULL;
// let it point to student object.
pIndividual = &SO;
// call getter on top of pIndividual pointer.
pIndividual->Getter();
}