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();
}
}
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.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.