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

I need help with this simple coding activity. I will award full points to the fi

ID: 647254 • Letter: I

Question

I need help with this simple coding activity. I will award full points to the first person whos code works.

#include <iostream>
#include <string>
#include <vector>
#include <sstream>

using namespace std;

class Person
{
public:
   Person(string name);
   virtual string toString() = 0;
protected:
   string name;
};

void printList(vector<Person*> list);

Person::Person(string name)
{
   this->name = name;
}

class Student : public Person
{
public:
   Student(string name, double GPA);
   string toString();
private:
   double GPA;
};

Student::Student(string name, double GPA) : Person(name)
{
   this->GPA = GPA;
}

string Student::toString()
{
   stringstream ss;
   ss << "Name: " << name << endl;
   ss << "GPA: " << GPA << endl;

   return ss.str();
}

//
// Create your faculty class here
//

int main()
{
//Code here

printList(my_list);

return 0;
}

void printList(vector<Person*> list)
{
   for (int i = 0; i < list.size(); i++)
   {
       cout << list[i]->toString();
   }
}

You have been given a Person class and a Student class which inherits from it. Create a simple Faculty class that also inherits From the Person class, such that both Student and Faculty pointers can be stored in a single vector. Your Faculty class should have a string for the name of the faculty member, and a string for the department they belong to. Your class should also implement the toString function required by the Person class. Follow the same format as the Student toString Function. When your program is run, you will be given 2 sets of 3 inputs which you should use to create the appropriate objects: a string representing the type (student or Faculty), a string for the name of the person, and either a double GPA for a student, or a string representing a department for a Faculty. Create pointers to the appropriate objects and store them both in a single vector called my_list.

Explanation / Answer

Add Simple condition to test the person is Student or Faculty.automatically the single list will be updated.

Just check the majo whether it is student or teacher.